1
任何人都可以指導我如何讀取/寫入由'NodeJS'中xml2js.Parser()解析的XML nodevalues?到目前爲止,我的代碼是作爲流程在NodeJs中使用索引讀取xml
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);
這裏的挑戰是標籤名稱在數據級別相同。如何閱讀。請幫忙。
我更新了args中的錯誤 –