Title Lua XML
Author(s) modified by LiXizhi to meet our specification
Date 2007/9/22
File script/ide/LuaXML.lua


Specifications: A tree is a Lua table representation of an element and its contents. The table must have a name key, giving the element name. The tree may have a attr key, which gives a table of all of the attributes of the element. Only string keys are relevant. If the element is not empty, each child node is contained in tree[1], tree[2], etc. Child nodes may be either strings, denoting character data content, or other trees.

Spec by example lz = commonlib.XML2Lua("first childboldsecond child") lz ={ { "first child", { "bold", attr={ }, n=1, name="b" }, "second child", attr={ justify="centered" }, n=3, name="paragraph" }, n=1 }

TIP Sample Code

local xmlRoot = commonlib.XML2Lua("<paragraph justify='centered'>first child<b>bold</b>second child</paragraph>")

Member Functions


implemented by LiXizhi, 2008.10.20 converting lua table to xml file. Please note the lua table must be in the format returned by commonlib.XML2Lua();

  • param bBeautify : if true, it will use indentations.


function commonlib.Lua2XmlString(input, bBeautify)


bBeautify if true, it will use indentations.
Topic revision: r1 - 2008-02-29 - LiXizhi
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback