commonlib.LuaXML
Lua XML
Description
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
}
Sample Code
NPL.load("(gl)script/ide/LuaXML.lua");
local xmlRoot = commonlib.XML2Lua("<paragraph justify='centered'>first child<b>bold</b>second child</paragraph>")
log(commonlib.Lua2XmlString(xmlRoot));
Member Functions
commonlib.Lua2XmlString
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.
syntax
function commonlib.Lua2XmlString(input, bBeautify)
parameters
input |
|
bBeautify |
if true, it will use indentations. |
Topic revision: r1 - 2008-02-29
- LiXizhi