Reputation: 2923
<doc>
<people>
<name sex="male">Harry Potter</name>
<age>18</age>
</people>
<people>
<name sex="male">hermione granger</name>
<age>18</age>
</people>
</doc>
From example xml I use xml2js to parse to object and I want to change the attribute name then I set the option in parseString() function but when I add any options in the function it doesn't work anymoe.
var xml2js = require('xml2js').Parser();
xml2js.parseString(xml,{attrkey:'att'}, function(err, result){
if(err) {throw err;}
console.log(JSON.stringify(result));
});
When I add option {attrkey:'att'} or others option to the function, it won't work. Do I have something wrong ?
Thanks for help !
Upvotes: 1
Views: 2873