node-xml2js
node-xml2js copied to clipboard
[parser] empty element results in "\n \n "
Parsing an empty element should result in an empty array, not string with \n's I see how this makes sense for a text node. Is there a way to get an empty array instead?
const xml2js = require('xml2js')
const xmlbuilder = new xml2js.Builder()
const xmlparser = new xml2js.Parser()
let x = `
<result timestamp="1602848610696">
<items>
</items>
</result>
`
let res = await xmlparser.parseStringPromise(x)
res = res.result
l('parser result', JSON.stringify(res))
outputs
parser result {
"$": {
"timestamp": "1602848610696"
},
"items": [
"\n \n "
]
}
Expected:
parser result {
"$": {
"timestamp": "1602848610696"
},
"items": []
}