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

preserveOrder with attributesGroupName option creates extra hirarchy #705

Open
6 of 7 tasks
floratmin opened this issue Jan 9, 2025 · 1 comment
Open
6 of 7 tasks

Comments

@floratmin
Copy link

  • 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?
  • Have you checked the docs for helpful APIs and examples?

Description

When I use both options together, then the attributeGroup gets wrapped by an extra object with the key specified by attributesGroupName.

Code

const parser = new  XMLParser({
    attributesGroupName: ':@',
    preserveOrder: true,
    ignoreAttributes: false,
});
const parsed = parser.parse('<root xmlns:ex="http://example.com"><p test="foo"></p></root>');
console.log(parsed);

Output

[
  {
    root: [
      p: [],
      ':@': {
        ':@': {
          '@_test': 'foo',
        },
      },
    ],
    ':@': {
      ':@': {
        '@_xmlns:ex': 'http://example.com',
      },
    },
  },
]

expected data

[
  {
    root: [
      p: [],
      ':@': {
        '@_test': 'foo',
      },
    ],
    ':@': {
      '@_xmlns:ex': 'http://example.com',
    },
  },
]

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

github-actions bot commented Jan 9, 2025

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.

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

No branches or pull requests

1 participant