title: PHP Dom Remove element leave contents
body: <p>I am trying to remove certain links depending on their ID tag, but leave the content of the link. For example I want to turn </p>
  
  <pre><code>Some text goes &lt;a href="http://www.domain.tdl/" id="remove"&gt;here&lt;/a&gt;
  </code></pre>
  
  <p>to</p>
  
  <pre><code>Some text goes here
  </code></pre>
  
  <p>I have tried using the below.</p>
  
  <pre><code>$dom = new DOMDocument;
  $dom-&gt;loadHtml(mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8"));
  $xp = new DOMXPath($dom);
  
  foreach($xp-&gt;query('//a[contains(@id="remove")]') as $oldNode) {
  $revised = strip_tags($oldNode);
  }
  
  $revised = mb_substr($dom-&gt;saveXML($xp-&gt;query('//body')-&gt;item(0)), 6, -7, "UTF-8");
  echo $revised;
  </code></pre>
  
  <p>roughly taken from <a href="https://stackoverflow.com/questions/4614434/how-can-i-use-xpath-and-dom-to-replace-a-node-element-in-php">here</a> but it just spits back the same content of <code>$html</code>.</p>
  
  <p>Any idea's on how I would achieve this?</p>