function hook_body($obj) { echo "

START

"; $doc = new DOMDocument(); libxml_use_internal_errors(true); $doc->loadHTML($obj); // loads your html $xpath = new DOMXPath($doc); // select all pre tags with attributes $nodelist = $xpath->query("//pre[@*]"); // iterate through selected nodes and print them for($i=0; $i < $nodelist->length; $i++) { $node = $nodelist->item($i); echo $node->nodeValue; //var_dump($node->nodeValue); } echo "

END

"; echo $obj; }