NaturalIntelligence / fast-xml-parser

Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback.
https://naturalintelligence.github.io/fast-xml-parser/
MIT License
2.43k stars 297 forks source link

Attribute in oneListGroup is not parsed correctly #634

Closed MHaz42 closed 17 hours ago

MHaz42 commented 5 months ago

Description

If an attribute is in a oneListGroup it isn't parsed as an attribute and simply disappear.

Input

const input = {
    main: [
        { _attr: { ID: "" } },
        { sub: { _attr: { value: "" } } },
        { sub: { _attr: { value: "" } } }
    ]
};

Code

const builder = new XMLBuilder({
      format: true,
      attributesGroupName: '_attr',
      attributeNamePrefix: '',
      oneListGroup: true,
      suppressEmptyNode: true,
      suppressBooleanAttributes: false,
      ignoreAttributes: false,
    });
builder.build(input);

Output

<main>
  <sub value=""/>
  <sub value=""/>
</main>

expected data

<main ID="">
  <sub value=""/>
  <sub value=""/>
</main>

Would you like to work on this issue?

Bookmark this repository for further updates. Visit SoloThought to know about recent features.

github-actions[bot] commented 5 months ago

We're glad you find this project helpful. We'll try to address this issue ASAP. You can vist https://solothought.com to know recent features. Don't forget to star this repo.