xml below to be parsed:
<ENVELOPE>
<ABC>
<DEF>apple</DEF>
<GHI>4</GHI>
<JKL>85</JKL>
</ABC>
<MNO>add</MNO>
<PQR></PQR>
<STU></STU>
</ENVELOPE>
and response after parsing:
{
"ENVELOPE": { "ABC": { "DEF": "apple", "GHI": "4", "JKL": "85" }, "MNO": "add" } }
The other two tags has been discarded by the xml2js parses. But i need it there to be empty atleast. Have tried using options of the parser but no luck yet
Here is my code to get the parser:
private getParser() {
let nameToLowerCase = (name: string): string => {
return name.toLowerCase();
}
let options: xml2js.Options = {
attrkey: '_',
charkey: '$',
explicitCharkey: true,
emptyTag: null,
normalize: true,
normalizeTags: true,
explicitArray: false,
trim: true,
tagNameProcessors: [nameToLowerCase],
attrNameProcessors: [nameToLowerCase]
};
return new xml2js.Parser(options);
}