Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

charkey cannot match name of child node #655

Open
scottwillman opened this issue Oct 16, 2022 · 0 comments
Open

charkey cannot match name of child node #655

scottwillman opened this issue Oct 16, 2022 · 0 comments

Comments

@scottwillman
Copy link

It appears that if the charkey matches the name of a child node the return value breaks in a very interesting way. Took me a while to figure out what was going on.

In this example:

const test = `
    <meters>
        <meter>
            <key>engine</key>
            <value>1747</value>
            <units>hrs</units>
        </meter>
    </meters>`;

With these options:

await xml2js.parseStringPromise(test, {
    explicitArray: false,
    charkey: 'value',
});

Produces this result:

{
    "meters": {
        "meter": {
            "value": "\n            \n            ,1747\n            \n        ",
            "key": "engine",
            "units": "hrs"
        }
    }
}

I'm not exactly sure what the right behaviour is here, but possibly worth warning in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant