-
-
Notifications
You must be signed in to change notification settings - Fork 355
Closed
Description
- Are you running the latest version?
- Have you included sample input, output, error, and expected output?
- Have you checked if you are using correct configuration?
- Did you try online tool?
Description
unpairedTags option doesn't work if not followed immediately by a paired tag, its parent consumes the next sibling.
Input
<root>
<a>
<unpaired>
</a>
<b>whatever</b>
</root>
Code
As per the API example:
const xmlDataStr = `
<root>
<a>
<unpaired>
</a>
<b>whatever</b>
</root>
`;
const options = {
unpairedTags: ["unpaired"]
};
const parser = new XMLParser(options);
const output = parser.parse(xmlDataStr);Output
{
"root": {
"a": {
"unpaired": "",
"b": "whatever"
}
}
}
Correct structure can be generated by changing input to:
<root>
<a>
<unpaired><pair>foo</pair>
</a>
<b>whatever</b>
</root>
which triggers correct parsing, eg:
{
"root": {
"a": {
"unpaired": "",
"pair": "foo"
},
"b": "whatever"
}
}
expected data
{
"root": {
"a": {
"unpaired": "",
},
"b": "whatever"
}
}
Would you like to work on this issue?
- Yes
- No
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels