有没有用 lua 写的读取xml 的库啊,有把luaxml 翻译成lua的也行,主要是不想加载动态链接库这种东西

如题所述

如果安装过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)
温馨提示:答案为网友推荐,仅供参考
相似回答