Skip to content

Invalid parsing of self-closing stopNode #435

@diegone

Description

@diegone
  • 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

Using preserveOrder: true on a self-closing stopNode results in the tag emitted as a text node.

Code

const XMLParser = require('fast-xml-parser').XMLParser;
const parser = new XMLParser({preserveOrder: true, stopNodes: ["*.foo"]});
console.dir(parser.parse('<root><foo name="bar"/></root>'), { depth: null });

Output

[
  {
    root: [ { foo: [ { '#text': '' } ] }, { '#text': 'foo name="bar"/>' } ]
  }
]

Expected Output

[
  {
    root: [
      { foo: [ { '#text': '' } ] }
    ]
  }
]

Would you like to work on this issue?

  • Yes
  • No

Bookmark this repository for further updates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions