We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Running
const util = require('util'); const xml2js = require('xml2js'); const xml = ` <?xml version="1.0" encoding="UTF-8"?> <test xmlns="http://example.com/namespace"> <value1>value1</value1> <value2></value2> <value3 xmlns="http://example.com/namespace">value3</value3> <value4 xmlns="http://example.com/namespace"></value4> </test> `; (async () => { const result = await new xml2js.Parser({ emptyTag: '--EMPTY--', explicitArray: false }).parseStringPromise(xml); console.log(util.inspect(result, false, null)); })();
prints following
{ test: { '$': { xmlns: 'http://example.com/namespace' }, value1: 'value1', value2: '--EMPTY--', value3: { _: 'value3', '$': { xmlns: 'http://example.com/namespace' } }, value4: { '$': { xmlns: 'http://example.com/namespace' } } } }
expected result for value4
value4
{ _: '--EMPTY--', '$': { xmlns: 'http://example.com/namespace' } }
The text was updated successfully, but these errors were encountered:
Found same issue here, it looks like it doesn't treat tags as empty when there is a tag attribute presented, not just limit to "xmlns" attribute.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Running
prints following
expected result for
value4
The text was updated successfully, but these errors were encountered: