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

Read empty attributes #578

Closed
4 of 6 tasks
Peterculazh opened this issue May 25, 2023 · 3 comments
Closed
4 of 6 tasks

Read empty attributes #578

Peterculazh opened this issue May 25, 2023 · 3 comments

Comments

@Peterculazh
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?

Description

I have xml which have empty attribute name. How I can read every attribute include empty attribute?

Input

<Tag xmlns="sql='urn:schemas-microsoft-com:xml-sql'"><Anotertag>
<MyTag test1='1' test2='2' test3='3' test4='4'  ='some value'/>
</Anotertag></Tag>

Code

const parser = new XMLParser({
  ignoreAttributes: false,
  attributeNamePrefix: '',
});
const file = fs.readFileSync(`downloads/${filename}`, 'utf-8');
const data = parser.parse(file);

Output

{
  Tag: {
    Anotertag: {
      MyTag: {
        test1: "1",
        test2: "2",
        test3: "3",
        test4: "4",
      },
    },
    xmlns: "sql='urn:schemas-microsoft-com:xml-sql'",
  },
}

expected data

{
  Tag: {
    Anotertag: {
      MyTag: {
        test1: "1",
        test2: "2",
        test3: "3",
        test4: "4",
        EMPTY_TAG1: "some value"
      },
    },
    xmlns: "sql='urn:schemas-microsoft-com:xml-sql'",
  },
}

Would you like to work on this issue?

  • Yes
  • No

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

@github-actions
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.

@amitguptagwl
Copy link
Member

Honestly speaking, it is a very particular case and has very less use cases.

@amitguptagwl
Copy link
Member

closing as no response. feel free to reopen it for further discussion

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

2 participants