Reputation: 2853
I am using the xml2json module to convert a XML payload into JSON, but the i am seeing the following
If i have the following
var xml = <Stat />;
var obj = xml2json.toJson(xml, {});
The obj["Stat"] is being picked up as empty {} rather than a empty "".
EDIT Lets say we have a nested xml structure
<?xml version="1.0" encoding="UTF-8"?>
<ABC>
<RECORD>
<STAT />
</RECORD>
</ABC>
Upvotes: 0
Views: 80
Reputation: 5233
You can not do that using xml2json
Use xml2js
instead:
var parseString = require('xml2js').parseString;
var xml = "<Stat />"
parseString(xml, function (err, result) {
console.dir(result); // { Stat: '' }
});
Upvotes: 2