title: Merging two xml documents using javascript?
body: <p>If I have two xml documents and store them into two javascript variables (xA and xB), how would I merge them together(with overwriting)?</p>
  
  <p>For example</p>
  
  <p>xA is</p>
  
  <pre><code>    &lt;cat&gt;
          &lt;name type="asdf" &gt;
              Bob
          &lt;/name&gt;
          &lt;color&gt;
              brown
          &lt;/color&gt;
          &lt;length&gt;
              8
          &lt;/length&gt;
      &lt;/cat&gt;
  </code></pre>
  
  <p>xB is </p>
  
  <pre><code>&lt;root&gt;
      &lt;cat&gt;
          &lt;name type="fdsa" &gt;
              Bob
          &lt;/name&gt;
          &lt;color&gt;
              black
          &lt;/color&gt;
          &lt;weight&gt;
              14
          &lt;/weight&gt;
      &lt;/cat&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>xB merge onto xA (stored as a variable xC) is</p>
  
  <pre><code>&lt;root&gt;
      &lt;cat&gt;
          &lt;name type="fdsa" &gt;
              Bob
          &lt;/name&gt;
          &lt;color&gt;
              black
          &lt;/color&gt;
          &lt;length&gt;
              8
          &lt;/length&gt;
          &lt;weight&gt;
              14
          &lt;/weight&gt;
      &lt;/cat&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>And then I can print xC as string or save it, etc.  How can I do this kind of merge in javascript?</p>