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

Fix #67 #68

Closed DusanNikolicc11 closed 2 years ago

DusanNikolicc11 commented 2 years ago

Fix #67

I tested with the following table:

{
    params = {
        o_param1 = {
            {
                i_param1 = "1",
                _attr = { ATTR = "ATTR_PARAM1"}
            },
            {
                i_param2 = "2",
                _attr = { ATTR = "ATTR_PARAM2"}
            },
        },

        o_param2 = {
            i_param1 = "1",
            i_param2 = {
                ii_param1 = "ii_param1",
                ii_param2 = "ii_param2"
            },
        }
    }
}

This table resulted into XML:

<params>
  <o_param1>
      <o_param1 ATTR="ATTR_PARAM1">
        <i_param1>1</i_param1>
      </o_param1>
      <o_param1 ATTR="ATTR_PARAM2">
        <i_param2>2</i_param2>
      </o_param1>
  </o_param1>

  <o_param2>
      <i_param1>1</i_param1>
      <i_param2>
        <ii_param2>ii_param2</ii_param2>
        <ii_param1>ii_param1</ii_param1>
      </i_param2>
  </o_param2>
</params>

Whereas I would've expected it to equal to:

<params>
    <o_param1 ATTR="ATTR_PARAM1">
        <i_param1>1</i_param1>
    </o_param1>
    <o_param1 ATTR="ATTR_PARAM2">
        <i_param2>2</i_param2>
    </o_param1>

    <o_param2>
        <i_param1>1</i_param1>
        <i_param2>
            <ii_param2>ii_param2</ii_param2>
            <ii_param1>ii_param1</ii_param1>
        </i_param2>
    </o_param2>
</params>

This PR should be a fix for the issue that me and @NicoAdrian are encountering

manoelcampos commented 2 years ago

I've just removed the examples

DusanNikolicc11 commented 2 years ago

I've just removed the new examples and included some acceptance tests based on the table structured provided on the PR text.

There is a test failure but about a different issue.

Awesome! Thanks very much for engaging