title: Error while removing an element from XML via PHP functions
body: <p>I am trying to Delete a user with particular ID from an xml file but facing following error:</p>
  
  <blockquote>
    <p>Argument 1 passed to
    DOMNode::removeChild() must be an
    instance of DOMNode, null given in
    delUser.php</p>
  </blockquote>
  
  <p><strong>XML file:</strong></p>
  
  <pre><code>&lt;currentUsers&gt;  
  &lt;user id="101" firstName="Klashinkof" p2p="Yes" priority="Low"/&gt;    
  &lt;user id="102" firstName="John" p2p="Yes" priority="High"/&gt; 
  &lt;/currentUsers&gt;
  </code></pre>
  
  <p><strong>code:</strong></p>
  
  <pre><code>  &lt;?php
       $id=101; //Test
  
  // SETUP $doc
  $doc = new DomDocument("1.0");
  $doc-&gt;preserveWhiteSpace = FALSE;
  $doc-&gt;validateOnParse = true; 
  $doc-&gt;Load('currUsers.xml');
  
  //REMOVE ID
      $user= $doc-&gt;getElementByID($id);
      $users= $doc-&gt;documentElement;
  
      if ($oldPerson = $users-&gt;removeChild($user)) {
          // worked
          echo "DELETED user {$id}";
          } else {
          return "Couldn't remove $id listing";
      }
  $doc-&gt;save(curr.xml); 
  ?&gt;
  </code></pre>