Let's say you have this xml:
<yyy:response xmlns:xxx='http://domain.com'>
<yyy:success>
<yyy:data>some-value</yyy:data>
</yyy:success>
</yyy:response>
How would I retrieve the value in between <yyy:data>
using Node.js?
Thanks.
node-xml2js library will help you.
var xml2js = require('xml2js');
var parser = new xml2js.Parser();
var xml = '\
<yyy:response xmlns:xxx="http://domain.com">\
<yyy:success>\
<yyy:data>some-value</yyy:data>\
</yyy:success>\
</yyy:response>';
parser.parseString(xml, function (err, result) {
console.dir(result['yyy:success']['yyy:data']);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With