Skip to content

XML to JSON parsing problem when end tag name contains space before the '>' #77

@sguimont

Description

@sguimont

We received from our customers not so perfect XML and sometime we received XML documents with end tag name with space. This space cause some strange JSON object output.

The name2 tag in the output must be link directly to person tag not within the name1 tag.

Input

<?xml version="1.0"?>
<any_name>
    <person>
        <name1>Jack 1</name1 >
        <name2>Jack 2</name2>
    </person>
</any_name>

Code

I used the online test page at https://naturalintelligence.github.io/fast-xml-parser/. I got the same issue when running with the code. I try many options in the test page and none has effect on the output generated.

Output

{
    "any_name": {
        "person": {
            "name1": {
                "#text": "Jack 1",
                "name2": "Jack 2"
            }
        }
    }
}

expected data

{
    "any_name": {
        "person": {
            "name1": "Jack 1",
            "name2": "Jack 2"
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions