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

Custom handler without endtag implementation fails to parse #43

Closed DeltaF1 closed 4 years ago

DeltaF1 commented 4 years ago

Attempting to use a handler without an "endtag" method fails to pop the stack and results in an "Incomplete XML Document" error.

This line

            if table.remove(self._stack) ~= tag.name then
                err(self, string.format("%s (/%s)", self._errstr.unmatchedTagErr, tag.name), f.pos)
            end

should be moved outside of the fexists check so that the parser will still pop the stack properly.

(For context as to why a handler wouldn't implement endtag, I'm writing a handler to extract only the text nodes out of an XML document for my application)

manoelcampos commented 4 years ago

Sorry for the late reply. In fact, the endtag() performs some additional processing, being a required function and the parsing doesn't work without it. Try to explain your use case to see if I can help.