Combine two XML files into one file
<p>I have the same question as here: <a href="https://stackoverflow.com/questions/982597/what-is-the-fastest-way-to-combine-two-xml-files-into-one">What is the fastest way to combine two xml files into one</a>
Unfortunately the answers given there don't work well.</p>

<p>I have exactly the same problem.
I have two files:</p>

<p>XML1:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
&lt;Results&gt;
  &lt;Memory&gt;
    &lt;instance00&gt;
      &lt;PageFaultsPersec&gt;
        &lt;sample time="9/8/2016 12:02:51 PM" value="1401.112" /&gt;
        &lt;sample time="9/8/2016 12:02:52 PM" value="242.3494" /&gt;
        &lt;sample time="9/8/2016 12:02:53 PM" value="303.1362" /&gt;
      &lt;/PageFaultsPersec&gt;
      &lt;AvailableBytes&gt;
        &lt;sample time="9/8/2016 12:02:51 PM" value="1.116967E+09" /&gt;
        &lt;sample time="9/8/2016 12:02:52 PM" value="1.11702E+09" /&gt;
        &lt;sample time="9/8/2016 12:02:53 PM" value="1.11761E+09" /&gt;
      &lt;/AvailableBytes&gt;
    &lt;/instance00&gt;
  &lt;/Memory&gt;
&lt;/Results&gt;
</code></pre>

<p>XML2:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
&lt;Results&gt;
  &lt;Processor&gt;
    &lt;instance_Total&gt;
      &lt;PercentProcessorTime&gt;
        &lt;sample time="9/8/2016 12:02:51 PM" value="18.4567" /&gt;
        &lt;sample time="9/8/2016 12:02:52 PM" value="3.032005" /&gt;
        &lt;sample time="9/8/2016 12:02:53 PM" value="0" /&gt;
      &lt;/PercentProcessorTime&gt;
      &lt;PercentUserTime&gt;
        &lt;sample time="9/8/2016 12:02:51 PM" value="17.04996" /&gt;
        &lt;sample time="9/8/2016 12:02:52 PM" value="3.03025" /&gt;
        &lt;sample time="9/8/2016 12:02:53 PM" value="0" /&gt;
      &lt;/PercentUserTime&gt;
      &lt;PercentPrivilegedTime&gt;
        &lt;sample time="9/8/2016 12:02:51 PM" value="0.7413027" /&gt;
        &lt;sample time="9/8/2016 12:02:52 PM" value="0" /&gt;
        &lt;sample time="9/8/2016 12:02:53 PM" value="0" /&gt;
      &lt;/PercentPrivilegedTime&gt;
    &lt;/instance_Total&gt;
  &lt;/Processor&gt;
&lt;/Results&gt;
</code></pre>

<p>I want to get:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
&lt;Results&gt;
  &lt;Memory&gt;
    &lt;instance00&gt;
      &lt;PageFaultsPersec&gt;
        &lt;sample time="9/8/2016 12:02:51 PM" value="1401.112" /&gt;
        &lt;sample time="9/8/2016 12:02:52 PM" value="242.3494" /&gt;
        &lt;sample time="9/8/2016 12:02:53 PM" value="303.1362" /&gt;
      &lt;/PageFaultsPersec&gt;
      &lt;AvailableBytes&gt;
        &lt;sample time="9/8/2016 12:02:51 PM" value="1.116967E+09" /&gt;
        &lt;sample time="9/8/2016 12:02:52 PM" value="1.11702E+09" /&gt;
        &lt;sample time="9/8/2016 12:02:53 PM" value="1.11761E+09" /&gt;
      &lt;/AvailableBytes&gt;
    &lt;/instance00&gt;
  &lt;/Memory&gt;
  &lt;Processor&gt;
    &lt;instance_Total&gt;
      &lt;PercentProcessorTime&gt;
        &lt;sample time="9/8/2016 12:02:51 PM" value="18.4567" /&gt;
        &lt;sample time="9/8/2016 12:02:52 PM" value="3.032005" /&gt;
        &lt;sample time="9/8/2016 12:02:53 PM" value="0" /&gt;
      &lt;/PercentProcessorTime&gt;
      &lt;PercentUserTime&gt;
        &lt;sample time="9/8/2016 12:02:51 PM" value="17.04996" /&gt;
        &lt;sample time="9/8/2016 12:02:52 PM" value="3.03025" /&gt;
        &lt;sample time="9/8/2016 12:02:53 PM" value="0" /&gt;
      &lt;/PercentUserTime&gt;
      &lt;PercentPrivilegedTime&gt;
        &lt;sample time="9/8/2016 12:02:51 PM" value="0.7413027" /&gt;
        &lt;sample time="9/8/2016 12:02:52 PM" value="0" /&gt;
        &lt;sample time="9/8/2016 12:02:53 PM" value="0" /&gt;
      &lt;/PercentPrivilegedTime&gt;
    &lt;/instance_Total&gt;
  &lt;/Processor&gt;
&lt;/Results&gt;
</code></pre>

<p>As I said, I tried answers, that were given in a link, but some of them don't work at all, and some just join two files without putting child elements properly.</p>

<p>The XML files are real files on a disk, not just strings.</p>