Skip to content

XML sequential order is not respected #13

@pmaziere

Description

@pmaziere

Hi,

when a xml document contains several instances of 2 different kinds of XML tags , xml2json regroups them in 2 different json arrays, ignoring the original sequence of the xml document.
Example:

<xml>
<tag1 id="1"/>
<tag1 id="2"/>
<tag2 id="1"/>
<tag2 id="2"/>
<tag1 id="3"/>
</xml>

gives this result:

{"xml":{
"tag1":[{"@id":"1"},{"@id":"2"},{"@id":"3"}],
"tag2":[{"@id":"1"},{"@id":"2"}]
}

which is understandable because the standard says that the names within an object SHOULD be unique.

To conserve this sequential information in the resulting json, I was expecting something like:

{"xml":{
"tag1[0]":[{"@id":"1"},{"@id":"2"}],
"tag2":[{"@id":"1"},{"@id":"2"}],
"tag1[1]":{"@id":"3"}
}

But someone may have a better approach to propose.

Could it be considered as an optional feature ?

thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions