1var xml2js = require('xml2js');
2var xml = "<config><test>Hello</test><data>SomeData</data></config>";
3
4var extractedData = "";
5var parser = new xml2js.Parser();
6parser.parseString(xml, function(err,result){
7 //Extract the value from the data element
8 extractedData = result['config']['data'];
9 console.log(extractedData);
10});
11console.log("Note that you can't use value here if parseString is async; extractedData=", extractedData);