I'm using xml2js npm to parse xml to json and everything goes well except in xml file, there is an attribute key
<ht:approx_traffic>20,000+</ht:approx_traffic>
and xml2js parses it in json like this
"ht:approx_traffic": [
"20,000+"
]
Is there a way that I can get rid of the colon there? Thanks.
I just simply use this to parse
var fs = require('fs'),
xml2js = require('xml2js');
var parser = new xml2js.Parser();
fs.readFile(__dirname + '/foo.xml', function(err, data) {
parser.parseString(data, function (err, result) {
console.dir(result);
console.log('Done');
});
});
approx_traffic?stripPrefix: strips the xml namespace prefix. E.g <foo:Bar/> will become 'Bar'. (N.B.: the xmlns prefix is NOT stripped.)see https://www.npmjs.com/package/xml2js#processing-attribute-tag-names-and-values.