lua-users home
lua-l archive

Re: luaxml nested entities

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Chris Datfung once stated:
> The luaxml documentation demonstrates how to create simple non-nested XML
> structures. How can I use luaxml to create nested entities, e.g.:
> 
> <john>
> <face>
> <eyes>brown</eyes>
> <hair>blond</hair>
> </face>
> </john>
 If I understand your question, then this should work:
	require "LuaXml"
	-- create a table that will be converted to XML
	doc =
	{
	 [0] = "john",
	 [1] =
	 {
	 [0] = "face",
	 [1] =
	 {
	 [0] = "eyes",
	 [1] = "brown",
	 }, 
	 [2] = 
	 {
	 [0] = "hair",
	 [1] = "blond",
	 }, 
	 }, 
	} 
 
	-- convert the table to an XML object
	doc = xml.new(doc)
	print(doc)
 -spc

AltStyle によって変換されたページ (->オリジナル) /