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.53k stars 303 forks source link

i've got a challenge with leading zeros #547

Closed thuus closed 1 year ago

thuus commented 1 year ago

Checklist

### Input

Code

const { XMLParser, XMLBuilder, XMLValidator } = require("fast-xml-parser");

const options = {
    parseTrueNumberOnly: true  //if true then values like "+123", or "0123" will not be parsed as number.
};

const xmlInput = '<item>08</item>';
console.log(xmlInput);  

const parser = new XMLParser(options);
let jsonData = parser.parse(xmlInput);
console.log(JSON.stringify(jsonData));

const builder = new XMLBuilder();
const xmlOutput = builder.build(jsonData,options)
console.log(xmlOutput);

Output

8

expected data

08

Would you like to work on this issue?

Bookmark 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.

amitguptagwl commented 1 year ago

Please check the docs