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(); }
/** * Setup the XPath object. */ private function setupXPath() { $this->xpath = new DOMXPath($this); $this->xpath->registerNamespace("php", "http://php.net/xpath"); $this->xpath->registerPHPFunctions(); }