title: php dom with xpath to remove tag
body: <p>I have a xml which the format is like this:</p>
  
  <pre><code>&lt;root&gt;
      &lt;a&gt;1&lt;/a&gt;
      &lt;b&gt;2&lt;/b&gt;
      &lt;c&gt;&lt;/c&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>This is the code I have tried: </p>
  
  <pre><code>$to = 3;
  $dom = new DOMDocument();
  $dom-&gt;formatOutput = true;
  $dom-&gt;preserveWhiteSpace = false;
  $dom-&gt;load("../xxx.xml");
  $xpath = new DOMXPath($dom);
  $query = "/root/*[position()=$to]";
  $nodes = $xpath-&gt;query($query);
  $node = $nodes[0];
  $dom-&gt;removeChild($node);
  $dom-&gt;save("../xxx.xml", LIBXML_NOEMPTYTAG);
  </code></pre>
  
  <p>How can I delete the tag with name "c" ?</p>