codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?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;
Private
[
?
]
Run code
Submit