Node.jsを使用してXML文字列から値を取得する方法
How Get Value From Xml String With Node
解決:
node-xml2jsライブラリが役に立ちます。
var xml2js = require( 'xml2js'); var parser = new xml2js.Parser(); var xml = ' some-value '; parser.parseString(xml、function(err、result){console.dir(result ['yyy:success'] ['yyy:data']);});
あなたはカマロでそれをより簡単にすることができます
const camaro = require( 'camaro')const xml = `some-value` const template = {data: '// yyy:data'} console.log(camaro(xml、template))出力:
{データ: 'some-value'}