在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):Cluain/Lua-Simple-XML-Parser开源软件地址(OpenSource Url):https://github.com/Cluain/Lua-Simple-XML-Parser开源编程语言(OpenSource Language):Lua 100.0%开源软件介绍(OpenSource Introduction):Installation
Parsing XML<test one="two">
<three four="five" four="six"/>
<three>eight</three>
<nine ten="eleven">twelve</nine>
</test> You can access values in two ways: Using the simple method: xml.test["@one"] == "two"
xml.test.nine["@ten"] == "eleven"
xml.test.nine:value() == "twelve"
xml.test.three[1]["@four"][1] == "five"
xml.test.three[1]["@four"][2] == "six"
xml.test.three[2]:value() == "eight" or if your XML is a little bit more complicated you can do it like this: xml:children()[1]:name() == "test"
xml:children()[1]:children()[2]:value() == "eight"
xml:properties()[1] == {name = "one", value = "two"} LimitationsThere's no support for namespaces. When I see namespaces I immediately start to remember days when I worked at corporate. We had to use namespaces only because XML was so convoluted we would not be able to handle it without them. In the end XML parsing took longer for some APIs then actual logic of the API. If you're in this situation it is better to step back and do something about it rather than asking for namespace support. I am using this module to read fairly simple XML. Even if it is a large XML string, the structure is still simple, so I was not able to test it properly. Please create a new Issue if you spot a problem. Please take a loook at xmlTest.lua for an example of use. Final notesThis is a modified version of Corona-XML-Module by Jonathan Beebe which in turn is based on Alexander Makeev's Lua-only XML parser found here |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论