答案 0 :(得分:2)
放手一搏;
var xml2js = require('xml2js');
var xml = "<body><row><col>firstrow1</col><col>firstrow2</col><col>firstrow3</col></row><row><col>secondrow1</col><col>secondrow2</col><col>secondrow3</col></row></body>";
var extractedData = "";
var parser = new xml2js.Parser();
parser.parseString(xml, function (err, result) {
//Extract the value from the data element
extractedData = result['body']['row']['col[0]'];
console.log(extractedData);
});
console.log(extractedData);