Skip to content

Attribute in oneListGroup is not parsed correctly #634

@MHaz42

Description

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

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?

  • Yes
  • No

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

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