Leonidas-from-XIV / node-xml2js

XML to JavaScript object converter.
MIT License
4.84k stars 596 forks source link

Builder when a property is undefined should not render in the XML #652

Open Raffaello opened 1 year ago

Raffaello commented 1 year ago

having a simple object like (typescript):

{
 keyA: "keyA",
 keyB: undefined
}

the resulting Builder of that object it would be something like

<xml>
 <keyA>keyA</KeyA>
 </keyB>
</xml>

it would be better having an option in the builder that will prune those empty elements, so it can be achieved this result instead

<xml>
 <keyA>keyA</KeyA>
</xml>
meeting-you commented 1 year ago

you can build object like:

{
    "xml": {
        "keyA": {
            "_": "keyA"
        }
    }
}

keyB can control by js

Raffaello commented 1 year ago

you can build object like:

{
    "xml": {
        "keyA": {
            "_": "keyA"
        }
    }
}

keyB can control by js

i don't understand what you mean. you posted a JSON. what i am asking is to prune the empty XML tags in case there are.