Closed waghcwb closed 1 year ago
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.
Please check strnum
option and library for appropriate configuration.
Hi, you can set parseTagValue: false
inside the options to avoid having strnum
parse the value for you.
let options = {
parseTagValue: false,
}
let parser = new XMLParser(options)
let object = parser.parse(`
<?xml version="1.0"?>
<any_name>
<person>
<phone>600.00</phone>
</person>
</any_name>
`)
console.info(object)
// { '?xml': '', any_name: { person: { phone: '600.00' } } }
You can also specify a custom tag parser inside the options
object (tagValueProcessor
property) to handle different cases based on your needs:
let options = {
parseTagValue: false,
tagValueProcessor: (tagName, tagValue) => {
if (typeof tagValue === 'string') {
return "HELLO!";
} else if (tagValue === undefined || tagValue === null) {
return null;
}
return tagValue.toString();
}
}
let parser = new XMLParser(options)
let object = parser.parse(`
<?xml version="1.0"?>
<any_name>
<person>
<phone>600.00</phone>
</person>
</any_name>
`)
console.info(object)
// { '?xml': '', any_name: { person: { phone: "HELLO!" } } }
I hope the issue is not anymore, or you can start the discussion thread.
Description
I want to know how to parse values as strings, because the parse is changing data in my XML
Code
Output
expected data
Would you like to work on this issue?