commonlib.LuaXML

Lua XML

Title Lua XML
Author(s) http://lua-users.org/wiki/XmlTree modified by LiXizhi to meet our specification
Date 2007/9/22
File script/ide/LuaXML.lua

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 }

TIP 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
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback