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

Properly restore stack value in dom handler #27

Closed zauguin closed 4 years ago

zauguin commented 4 years ago

Currently the DOM handler keeps track of the current element using a stack, but when removing the last element from the stack the previous element isn't restored to self.current. Therefore subsequent elements appear nested, e.g. a document like

<a>
  <b />
  <c />
</a>

is parsed as if it was

<a>
  <b>
    <c />
  </b>
</a>

This can be fixed by assigning the top of the stack to self.current after removing an element from the stack.

manoelcampos commented 4 years ago

Thanks for your contribution.