我已经将模拟的 XML 数据存储在硬盘上(称为 simmedData.xml)。我还有通过 Web 端点 ( ) 出售的“真实”数据(“真实”数据是动态的http://localhost:8079/realData
)。
XML 文档的格式完全相同,但我想将它们“合并”到一个可用的端点http://localhost:8080/mergedData
。
我想使用node.js 来托管mergedData 端点——当请求mergedData 时,有没有一种简单的方法可以将这些xml 文档合并在一起?
例如:
simmedData.xml
<site:Tracks xmlns:site='http://mysite/site'>
<site:track id='1' latitude='37.82091918923291' longitude='128.87375778822812' altitude='9753.6005859375' bearing='10.542624087704585' speedInKnots='454.6067199707031' />
<site:track id='2' latitude='37.45048387959727' longitude='129.49111126654887' altitude='9144.0' bearing='190.90400586790983' speedInKnots='436.89837646484375' />
</site:Tracks>
http://localhost:8079/realData
<site:Tracks xmlns:site='http://mysite/site'>
<site:track id='1001' latitude='39.82093291' longitude='128.87375722812' altitude='9753.60375' bearing='10.542704585' speedInKnots='454.6707031' />
<site:track id='1002' latitude='39.387959727' longitude='129.4126654887' altitude='9144.0' bearing='90.90790983' speedInKnots='436.8984375' />
<site:track id='1003' latitude='40.82093291' longitude='138.87375722812' altitude='9753.5' bearing='10.542704585' speedInKnots='454.6707031' />
<site:track id='1004' latitude='40.387959727' longitude='139.4126654887' altitude='9124.0' bearing='90.90790983' speedInKnots='436.8984375' />
</site:Tracks>
http://localhost:8080/mergedData
<site:Tracks xmlns:site='http://mysite/site'>
<site:track id='1' latitude='37.82091918923291' longitude='128.87375778822812' altitude='9753.6005859375' bearing='10.542624087704585' speedInKnots='454.6067199707031' />
<site:track id='2' latitude='37.45048387959727' longitude='129.49111126654887' altitude='9144.0' bearing='190.90400586790983' speedInKnots='436.89837646484375' />
<site:track id='1001' latitude='39.82093291' longitude='128.87375722812' altitude='9753.60375' bearing='10.542704585' speedInKnots='454.6707031' />
<site:track id='1002' latitude='39.387959727' longitude='129.4126654887' altitude='9144.0' bearing='90.90790983' speedInKnots='436.8984375' />
<site:track id='1003' latitude='40.82093291' longitude='138.87375722812' altitude='9753.5' bearing='10.542704585' speedInKnots='454.6707031' />
<site:track id='1004' latitude='40.387959727' longitude='139.4126654887' altitude='9124.0' bearing='90.90790983' speedInKnots='436.8984375' />
</site:Tracks>