manoelcampos / xml2lua

XML Parser written entirely in Lua that works for Lua 5.1+. Convert XML to and from Lua Tables 🌖💱
MIT License
290 stars 74 forks source link

clearing results to be able to parse multiple xml files? #93

Closed ownlyme closed 6 months ago

ownlyme commented 1 year ago

when i parse multiple xml files, the additional files seem to get added to the same table and there doesn't seem to be a way to clear the results

tuananh commented 11 months ago

i have the same issue. how do i clear it before i can pass another xml string?

nilzao commented 6 months ago

the trick is

handler = handler:new()

edit example3.lua, add these lines at end to see the example:

print("\nUsing New handler instance")
handler = handler:new()
parser = xml2lua.parser(handler)
parser:parse(xml)
xml2lua.printable(handler.root)