Advertisement
Guest User

Untitled

a guest
Nov 4th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement