<?php
$html = 'This is a quick snippet that often comes in handy: <pre>[code]blah blah[/code]</pre>';
$dom = new DOMDocument;
$dom->loadXML('<customtag>'.$html.'</customtag>');
$xpath = new DOMXPath($dom);
$query = '//pre';
$entries = $xpath->query($query);
foreach($entries as $one){
$newelement = $dom->createTextNode('Some new node!');
$one->parentNode->replaceChild($newelement, $one);
}
$html = $dom->childNodes->item(0)->nodeValue;
echo $html;