NaturalIntelligence / fast-xml-parser

Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback.
https://naturalintelligence.github.io/fast-xml-parser/
MIT License
2.49k stars 302 forks source link

unable to use the value "true" in an attribute #500

Closed angrymarker closed 1 year ago

angrymarker commented 1 year ago

Checklist

Input object: ``` { "iteration": { "@_test": "true", } } ```

Code

``

const { XMLBuilder } = require('fast-xml-parser');
builder = new XMLBuilder({ ignoreAttributes: false, format: true, suppressEmptyNode: true });
builder.build({
    "iteration": {
        "@_test": "true",
    }
})


### Output

<?xml version="1.0"?>
<iteration test></iteration>

### expected data

<?xml version="1.0"?>
<iteration test="true"></iteration>

**Would you like to work on this issue?**
<!-- choose one by changing [ ] to [x] -->
- [ ] Yes
- [ X] No

[Bookmark](https://github.com/NaturalIntelligence/fast-xml-parser/stargazers) this repository for further updates.
github-actions[bot] commented 1 year ago

I'm glad you find this repository helpful. I'll try to address your issue ASAP. You can watch the repo for new changes or star it.

angrymarker commented 1 year ago

this is good html, but not good xml. throwing into an xml linter or internet explorer bombs out, expecting the attribute to equal something

The XML page cannot be displayed

Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


A name contained an invalid character. Error processing resource 'file://x

  <Package isAddtPkg>

The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the [Refresh](javascript:location.reload()) button, or try again later. -------------------------------------------------------------------------------- A name contained an invalid character. Error processing resource 'file:/X
amitguptagwl commented 1 year ago

Have you tried 'suppressBooleanAttributes:false' ?

amitguptagwl commented 1 year ago

closing as no response. Please reopen if issue still exist