[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: luaxml nested entities
 
- From: Sean Conner <sean@...>
 
- Date: Tue, 15 Oct 2013 16:15:20 -0400
 
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