問題タブ [xml2js]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
node.js - ノード XML パーサーを使用した XLIFF の解析の問題
xml2js ライブラリを使用して XLIFF ファイルを解析しようとしています。すべて正常に動作していますが、そのようなものがある場合:<source>Welcome to <x id="INTERPOLATION" equiv-text="{{ title }}"/> my friend</source>
を取得し[{"_":"Welcome to my friend","x":[{"$":{"id":"INTERPOLATION","equiv-text":"{{ title }}"}}]}]
ます。私は基本的に文の一部の順序を失っています。私は3つの部分の配列を取得することを期待しています:
しかし、代わりに私は得ています:
文字列をもう一度再作成しようとすると、<source>Welcome to my friend<x id="INTERPOLATION" equiv-text="{{ title }}"/></source>
この XML パーサーまたは他のパーサーで解決する方法はありますか?