Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 4th, 2013  |  syntax: PHP  |  size: 0.53 KB  |  views: 38  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function hook_body($obj)
  2. {
  3.    echo "<h1>START</h1>";  
  4.    $doc = new DOMDocument();
  5.    libxml_use_internal_errors(true);
  6.    $doc->loadHTML($obj); // loads your html
  7.    $xpath = new DOMXPath($doc);
  8.  
  9.    // select all pre tags with attributes
  10.    $nodelist = $xpath->query("//pre[@*]");
  11.    // iterate through selected nodes and print them
  12.    for($i=0; $i < $nodelist->length; $i++) {
  13.        $node = $nodelist->item($i);
  14.        echo $node->nodeValue; //var_dump($node->nodeValue);
  15.    }
  16.  
  17.    echo "<h1>END</h1>";
  18.    echo $obj;
  19. }
clone this paste RAW Paste Data