title: XML in Node.js (Using Javascript)
body: <p>I've got simulated XML data stored the hard disk (called simmedData.xml).  I've also got 'real' data (the 'real' data is dynamic) vended through a web endpoint (<code>http://localhost:8079/realData</code>).  </p>
  
  <p>The format of the XML documents are exactly the same, but I would like to 'merge' them into one endpoint available at <code>http://localhost:8080/mergedData</code>.</p>
  
  <p>I want to use node.js to host the mergedData endpoint  -- Is there a simple way to merge these xml documents together when mergedData is requested?</p>
  
  <p>For example:</p>
  
  <p><strong>simmedData.xml</strong></p>
  
  <pre><code>&lt;site:Tracks xmlns:site='http://mysite/site'&gt;
    &lt;site:track id='1' latitude='37.82091918923291' longitude='128.87375778822812' altitude='9753.6005859375' bearing='10.542624087704585' speedInKnots='454.6067199707031' /&gt;
    &lt;site:track id='2' latitude='37.45048387959727' longitude='129.49111126654887' altitude='9144.0' bearing='190.90400586790983' speedInKnots='436.89837646484375' /&gt;
  &lt;/site:Tracks&gt;
  </code></pre>
  
  <p><strong>http://localhost:8079/realData</strong></p>
  
  <pre><code>&lt;site:Tracks xmlns:site='http://mysite/site'&gt;
    &lt;site:track id='1001' latitude='39.82093291' longitude='128.87375722812' altitude='9753.60375' bearing='10.542704585' speedInKnots='454.6707031' /&gt;
    &lt;site:track id='1002' latitude='39.387959727' longitude='129.4126654887' altitude='9144.0' bearing='90.90790983' speedInKnots='436.8984375' /&gt;
    &lt;site:track id='1003' latitude='40.82093291' longitude='138.87375722812' altitude='9753.5' bearing='10.542704585' speedInKnots='454.6707031' /&gt;
    &lt;site:track id='1004' latitude='40.387959727' longitude='139.4126654887' altitude='9124.0' bearing='90.90790983' speedInKnots='436.8984375' /&gt;
  &lt;/site:Tracks&gt;
  </code></pre>
  
  <p><strong>http://localhost:8080/mergedData</strong></p>
  
  <pre><code>&lt;site:Tracks xmlns:site='http://mysite/site'&gt;
    &lt;site:track id='1' latitude='37.82091918923291' longitude='128.87375778822812' altitude='9753.6005859375' bearing='10.542624087704585' speedInKnots='454.6067199707031' /&gt;
    &lt;site:track id='2' latitude='37.45048387959727' longitude='129.49111126654887' altitude='9144.0' bearing='190.90400586790983' speedInKnots='436.89837646484375' /&gt;
    &lt;site:track id='1001' latitude='39.82093291' longitude='128.87375722812' altitude='9753.60375' bearing='10.542704585' speedInKnots='454.6707031' /&gt;
    &lt;site:track id='1002' latitude='39.387959727' longitude='129.4126654887' altitude='9144.0' bearing='90.90790983' speedInKnots='436.8984375' /&gt;
    &lt;site:track id='1003' latitude='40.82093291' longitude='138.87375722812' altitude='9753.5' bearing='10.542704585' speedInKnots='454.6707031' /&gt;
    &lt;site:track id='1004' latitude='40.387959727' longitude='139.4126654887' altitude='9124.0' bearing='90.90790983' speedInKnots='436.8984375' /&gt;
  &lt;/site:Tracks&gt;
  </code></pre>