manoelcampos / xml2lua

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

Can't parse `gl.xml` #31

Closed v1993 closed 4 years ago

v1993 commented 4 years ago

Tried to parse official OpenGL specifications and met a major problem: function names aren't preserved. Example to reproduce the problem:

local xml2lua = require("xml2lua")
local handler = require("xmlhandler.tree")
local json = require 'json'

--local data = assert(io.open('gl.xml', 'r')):read('*a')
local data = '<proto>void <name>glEnableIndexedEXT</name></proto>'

local parser = xml2lua.parser(handler)
parser:parse(data)

print(json.encode(handler.root))

Result: {"proto":"void"}

manoelcampos commented 4 years ago

<proto>void <name>glEnableIndexedEXT</name></proto> is not a valid XML.

void is neither a tag, attribute or value.

v1993 commented 4 years ago

Is it really invalid? XML validators report this as valid string and I highly doubt people would use invalid XML for such things. Other libraries (not for lua sadly) parse this well too.

manoelcampos commented 4 years ago

It may be valid, but at least it is a strange XML. Check issue #35. There may be XML parsers that accept this type of XML, but some such as Java parsers don't.

manoelcampos commented 4 years ago

Hey @v1993
Check the latest release and PR #40. Maybe it fixes your issue.

v1993 commented 4 years ago

@manoelcampos No, my test code from the first message still fails with exactly same result. I've upgraded to xml2lua 1.3-5 using luarocks.

manoelcampos commented 4 years ago

It was just a try. Sorry that it doesn't work. But your xml doesn't have a common structure.