-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathexample2.lua
More file actions
executable file
·25 lines (19 loc) · 870 Bytes
/
example2.lua
File metadata and controls
executable file
·25 lines (19 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env lua
---Shows how to parse more than one XML file in the same application.
--@author Manoel Campos da Silva Filho - http://manoelcampos.com
local xml2lua = require("xml2lua")
print("xml2lua v" .. xml2lua._VERSION.."\n")
--Uses a handler that converts the XML to a Lua table
local handler = require("xmlhandler.tree")
----------------------- people1.xml parse code -----------------------
print("people1.xml")
local peopleHandler = handler:new()
local peopleParser = xml2lua.parser(peopleHandler)
peopleParser:parse(xml2lua.loadFile("people1.xml"))
xml2lua.printable(peopleHandler.root)
----------------------- books.xml parse code -----------------------
print("\n\nbooks.xml")
local booksHandler = handler:new()
local booksParser = xml2lua.parser(booksHandler)
booksParser:parse(xml2lua.loadFile("books.xml"))
xml2lua.printable(booksHandler.root)