title: Concatenating two XML files using JavaScript/AJAX
body: <p>I have been tasked with splitting an XML file into two parts for ease of editing.</p>
  
  <p>But all the existing codebase is designed to treat it as a single file. </p>
  
  <p>As a middle ground (due to a paucity of time) I decided to split the files, but simply concatenate the split files by using the following code</p>
  
  <pre><code>    var xmlDoc;
      xmlhttp.open("GET","distributome-relations.xml",false);
      xmlhttp.send();
      xmlDoc = xmlhttp.responseXML;
      xmlhttp=createAjaxRequest();
      xmlhttp.open("GET","distributome-references.xml",false);
      xmlhttp.send();
      xmlDoc = xmlDoc+xmlhttp.responseXML;
              try{
          DistributomeXML_Objects=xmlDoc.documentElement.childNodes;
      }catch(error){
          DistributomeXML_Objects=xmlDoc.childNodes;
      }
  </code></pre>
  
  <p>Which doesn't seem to work while the original code </p>
  
  <pre><code>xmlhttp.open("GET","Distributome.xml",false);
      xmlhttp.send();
      if (!xmlhttp.responseXML.documentElement &amp;&amp; xmlhttp.responseStream)
          xmlhttp.responseXML.load(xmlhttp.responseStream);
      xmlDoc = xmlhttp.responseXML;
      try{
          DistributomeXML_Objects=xmlDoc.documentElement.childNodes;
      }catch(error){
          DistributomeXML_Objects=xmlDoc.childNodes;
      }
  </code></pre>
  
  <p>Works perfectly fine.</p>
  
  <p>I'm not sure how to proceed with this. </p>
  
  <p>I have simply split the file </p>
  
  <p><a href="http://www.distributome.avinashc.com/avinash/Distributome.xml" rel="nofollow">http://www.distributome.avinashc.com/avinash/Distributome.xml</a> into </p>
  
  <p><a href="http://www.distributome.avinashc.com/avinash/distributome-relations.xml" rel="nofollow">http://www.distributome.avinashc.com/avinash/distributome-relations.xml</a> and 
  <a href="http://www.distributome.avinashc.com/avinash/distributome-references.xml" rel="nofollow">http://www.distributome.avinashc.com/avinash/distributome-references.xml</a> </p>
  
  <p>The last two files will appear improperly formatted because only a simple concatenation of the two files is expected to be a valid XML document.</p>
  
  <p>I suspect that this is due to the use of the responseXML method and that I should use an alternate method.</p>
  
  <p>Is there a better way to do this. I would welcome any suggestions, and of course - answers to my original question.</p>
  
  <p>Thanks</p>