private function cleanByCSS()
 {
     $xpath = new \DOMXpath($this->dom);
     $xpath->registerNamespace("php", "http://php.net/xpath");
     $xpath->registerPHPFunctions();
     foreach ($this->badCssSelector as $selector) {
         if ($nodeList = $xpath->query($selector)) {
             foreach ($nodeList as $node) {
                 $node->parentNode->removeChild($node);
             }
         }
     }
     return $this->dom->saveHTML();
 }
示例#2
0
 /**
  * Setup the XPath object.
  */
 private function setupXPath()
 {
     $this->xpath = new DOMXPath($this);
     $this->xpath->registerNamespace("php", "http://php.net/xpath");
     $this->xpath->registerPHPFunctions();
 }