title: DOM replaceChild not replacing all specified elements
body: <p>Consider the following code:</p>
  
  <pre><code>$xml = &lt;&lt;&lt;XML
  &lt;root&gt;
  &lt;region id='thisRegion'&gt;&lt;/region&gt;
  &lt;region id='thatRegion'&gt;&lt;/region&gt;
  &lt;/root&gt;
  XML;
  </code></pre>
  
  <hr>
  
  <pre><code>$partials['thisRegion'] = "&lt;p&gt;Here's this region&lt;/p&gt;";
  $partials['thatRegion'] = "&lt;p&gt;Here's that region&lt;/p&gt;";
  $DOM = new DOMDocument;
  $DOM-&gt;loadXML($xml);
  
  $regions = $DOM-&gt;getElementsByTagname('region');
  
  foreach( $regions as $region )
  {
      $id = $region-&gt;getAttribute('id');
      $partial = $DOM-&gt;createDocumentFragment();
      $partial-&gt;appendXML( $partials[$id] );
      $region-&gt;parentNode-&gt;replaceChild($partial, $region);
  
  }
  
  echo $DOM-&gt;saveXML();
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>&lt;root&gt;
  &lt;p&gt;Here's this region&lt;/p&gt;
  &lt;region id="thatRegion"/&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>I cannot for the life of me figure out why all of the region tags aren't being replaced.  This is a problem in my project, and at first I thought that it wasn't replacing elements I appended after the loadXML, but with some experimenting I haven't been able to narrow down the pattern here.</p>
  
  <p>I would appreciate a code correction to allow me to replace all  tags in a DOMDocument with a given Element Node.  I also wouldn't mind any input into a more efficient/practical way to execute this if I haven't found it.</p>
  
  <p>Thanks in advance!</p>
  
  <p>[edit] PHP 5.3.13</p>