wrong value assigned to empty tags
Here https://github.com/Leonidas-from-XIV/node-xml2js/blob/master/lib/xml2js.js#L386
obj = _this.options.emptyTag !== '' ? _this.options.emptyTag : emptyStr;
in case we don't pass emptyTag option, or we pass an empty string, emptyStr value is assigned to empty tags.
But as we can see here https://github.com/Leonidas-from-XIV/node-xml2js/blob/master/lib/xml2js.js#L371
if (obj[charkey].match(/^\s*$/) && !cdata) {
emptyStr = obj[charkey];
delete obj[charkey];
}
in case of newline / space characters emptyStr is set to their initial, non empty string value, no matter if we have trim option passed or no.
EDIT: emptyTag options for parser does nothing for me
Hi, i don't know if my issue is a duplicte of yours, but I'm looking for a solution to:
I have xml with empty tags like so:
<tag1>
</tag1>
When using xml2js parser, the JSON object I get is:
let json = {tag1: [ '\015\n ' ]}
when I try to do Object.keys(json.tag1).length
I get an error when I should be getting 0.
@ex37 Did you do any workaround for this issue? because I am also facing the same issue while parsing the XML to JSON.