Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content of tags was lost in arrays #4

Open
dlnsk opened this issue Jul 28, 2022 · 4 comments
Open

Content of tags was lost in arrays #4

dlnsk opened this issue Jul 28, 2022 · 4 comments

Comments

@dlnsk
Copy link

dlnsk commented Jul 28, 2022

In xml like this
<person id="1234">zzz<name a="qqq">John</name><name a="www">Doe</name></person>
strings "John" and "Doe" will be lost because the 'name' is an array.

@dantio
Copy link
Collaborator

dantio commented Jul 29, 2022

Thank you for remoporting this issue. It's been a while that I looked in to this lib. I'll try to fix it.

@dantio
Copy link
Collaborator

dantio commented Jul 29, 2022

Actually it looks correct:

xml2json('<person id="1234">Jane<name id="1234">John</name><name id="4321">Doe</name></person>');

Output:

{
            "person": {
                "_@attribute": "Jane",
                "id": "1234",
                "name": [{"_@attribute": "John", "id": "1234"}, {"_@attribute": "Doe", "id": "4321"}]
            }
}

Or what is your expected output @dlnsk ?

@dlnsk
Copy link
Author

dlnsk commented Aug 12, 2022

It was mystical :)

@dlnsk dlnsk closed this as completed Aug 12, 2022
@dlnsk
Copy link
Author

dlnsk commented Aug 12, 2022

Not an array but a bug :)

const xml = '<person id="1234" age="30"><name>John Doe</name>Person</person>';

output

{"person":{"id":"1234","age":"30","name":"John Doe"}}

'Person' is disappear.

@dlnsk dlnsk reopened this Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants