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

removeNSPrefix option doesn't work #596

Closed
4 of 6 tasks
prithwirajbose opened this issue Jul 4, 2023 · 3 comments
Closed
4 of 6 tasks

removeNSPrefix option doesn't work #596

prithwirajbose opened this issue Jul 4, 2023 · 3 comments

Comments

@prithwirajbose
Copy link

prithwirajbose commented Jul 4, 2023

  • Are you running the latest version? Yes
  • Have you included sample input, output, error, and expected output? Yes
  • Have you checked if you are using correct configuration? Yes
  • Did you try online tool? No

Description

As per Changelog, ignoreNameSpace option in V3 is change to removeNSPrefix in V4. However, this option doesn't seem to work. This is one of the critical options because it changes the output JSON tagnames completely, for an input XML which has namespaces in tag names.

Input

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header/> <soapenv:Body><Data>Hello</Data></soapenv:Body></soapenv:Envelope>

Code

const { XMLParser } = require("fast-xml-parser");
const fastXmlParser = new XMLParser();
var xmlParserOptions = {
    attrPrefix: "",
    textNodeName: "text",
    ignoreTextNodeAttr: false,
    removeNSPrefix: true,
    textNodeConversion: false
};
var json = fastXmlParser.parse(xmlBody, xmlParserOptions);

Output

{"?xml":"","soapenv:Envelope":{"soapenv:Header":"","soapenv:Body":{ "Data": "Hello" }}}

expected data

{"?xml":"","Envelope":{"Header":"","Body":{ "Data": "Hello" }}}

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

github-actions bot commented Jul 4, 2023

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.

@prithwirajbose
Copy link
Author

Can someone please provide an update?

@amitguptagwl
Copy link
Member

@prithwirajbose options are supposed to be passed in constructor not the parsing method. Check https://solothought.com/tutorial/fast-xml-parser-4.2-features/ for a few example how the library is supposed to be used.

Reopen the issue if you still face the problem.

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