0
我试图在节点中将XML解析为JSON。我正在使用xml2js。我想将Lodash合并到数组中的每个数字中,并使用相应的url将XML转换为JSON。当我使用下面的代码时,出现Non-whitespace before first tag
错误。任何想法我做错了什么?当在节点中将XML解析为JSON时,使用Lodash循环浏览https.get
const no = [78787878,78787879, 787878780];
_.forEach(no, https.get('https://tsdrapi.uspto.gov/ts/cd/casestatus/'+no+'/info.xml', function (res) {
res.on('data', function (chunk) {
response_data += chunk;
});
res.on('end', function() {
parser.parseString(response_data, function (err, result) {
if (err) {
console.log('Got error: ' + err.message);
} else {
console.log(util.inspect(result, false, null));
}
});
});
res.on('error', function (err) {
console.log('Got error: ' + err.message);
});
}));