コード例 #1
0
 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
ファイル: XMLDocument.php プロジェクト: mohiva/common
 /**
  * Setup the XPath object.
  */
 private function setupXPath()
 {
     $this->xpath = new DOMXPath($this);
     $this->xpath->registerNamespace("php", "http://php.net/xpath");
     $this->xpath->registerPHPFunctions();
 }