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

xd:string "0xF2" => 242 #536

Open luddwskater opened 1 year ago

luddwskater commented 1 year ago

Description

Parser transform hex to integer but builder doesn't transform back to hex but also transform hex (string) to integer.

Input

        <SupportedTesters>
            <SupportedTester>0xF2</SupportedTester>
        </SupportedTesters>

Code

const options = {
        ignoreAttributes: false,
        attributeNamePrefix : "@_",
        allowBooleanAttributes: true
    };

Output

SupportedTesters : SupportedTester : 242 [[Prot

expected data

0<F2 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

I've tried to improve you question but still not able to understand it completely. Please reformat it.

luddwskater commented 1 year ago

I've an element of type xd:string with value "0xF2" but this is transformed both by parser to json and also by builder to xml as number 242. It means in xml = "0xF2" becames 242 in json and "0xF2" in json became 242 in xml. Strange , i can't find any option to disable transformation from hex to number.

amitguptagwl commented 1 year ago

We use strnum npm package for the transformation. Check it's configuration and documentation please