Thursday, 27 April 2017

xml2js parser ignores the empty string in an array resulting in array size change

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



via Ankur

No comments:

Post a Comment