Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute in oneListGroup is not parsed correctly #634

Open
4 of 6 tasks
MHaz42 opened this issue Jan 19, 2024 · 1 comment · May be fixed by #653
Open
4 of 6 tasks

Attribute in oneListGroup is not parsed correctly #634

MHaz42 opened this issue Jan 19, 2024 · 1 comment · May be fixed by #653

Comments

@MHaz42
Copy link

MHaz42 commented Jan 19, 2024

  • 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.

Copy link

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.

a-rasin pushed a commit to a-rasin/fast-xml-parser that referenced this issue May 6, 2024
…ttributesGroupName

Don't ignore attributes when building to xml with oneListGroup and
attributesGroupName enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant