title: Copy DOMNodes from one DOMDocument to another
body: <p>I've been trying to combine two XML documents like this:</p>
  
  <pre><code>$def  = new DOMDocument( '1.0' );
  $rdef = new DOMDocument( '1.0' );
  $def-&gt;load( $path );
  $rdef-&gt;loadXML( $info );
  $r = $def-&gt;getElementsByTagName( 'repository' )-&gt;item( 0 );
  $s = $rdef-&gt;getElementsByTagName( 'repository' )-&gt;item( 0 );
  try {
      $r-&gt;appendChild( $s );
  }
  catch ( DOMException $e ) {
      SPConfig::debOut( get_class( $s ) );
      SPConfig::debOut( $e-&gt;getMessage() );
  }
  </code></pre>
  
  <p>The result is:</p>
  
  <pre><code>DOMElement
  Wrong Document Error
  </code></pre>
  
  <p>So it seems to me that <code>$rdef-&gt;getElementsByTagName( 'repository' )-&gt;item( 0 )</code> returns <em>DOMElement</em> object but the <a href="http://php.net/manual/domnodelist.item" rel="nofollow noreferrer">definition</a> says it should be <em>DOMNode</em> object.</p>
  
  <p>Any idea what is wrong about it?</p>