📜  如何读取 xml2js 中的 xml 元素 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:27.094000             🧑  作者: Mango

代码示例1
var xml2js = require('xml2js');
var xml = "HelloSomeData";

var extractedData = "";
var parser = new xml2js.Parser();
parser.parseString(xml, function(err,result){
  //Extract the value from the data element
  extractedData = result['config']['data'];
  console.log(extractedData);
});
console.log("Note that you can't use value here if parseString is async; extractedData=", extractedData);