å¦æå®è£
è¿luaå®æ¹æ¨èçç¼è¯å¨luaforwindowsçè¯ä½ å°±å¯ä»¥å»exampleéæ¾å°ä¸ä¸ªluaxml éé¢æ个test å°±æ¯æ¼ç¤ºç¨åº
代ç å¦ä¸
require('LuaXml')
-- load XML data from file "test.xml" into local table xfile
local xfile = xml.load("test.xml")
-- search for substatement having the tag "scene"
local xscene = xfile:find("scene")
-- if this substatement is found?
if xscene ~= nil then
-- å²rint it to screen
print(xscene)
-- print tag, attribute id and first substatement
print( xscene:tag(), xscene.id, xscene[1] )
end
-- create a new XML object and set its tag to "root"
local x = xml.new("root")
-- append a new subordinate XML object, set itstag to "child", and its content to 123
x:append("child")[1] = 123
print(x)
温馨提示:答案为网友推荐,仅供参考