のXMLをJSONに解析するときにLodashを使用してhttps.getをループするノードでXMLをJSONに解析しようとしています。私はxml2jsを使用しています。私はLodashを配列の各番号にループし、対応するURLを使用してXMLをJSONに変換したいと考えています。以下のコードを使用すると、Non-whitespace before first tag
エラーが発生します。私が間違っていることは何か考えていますか?Nodeで
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);
});
}));