public function QueryPath::replaceAll in QueryPath 6
Same name and namespace in other branches
- 7.3 QueryPath/QueryPath.php \QueryPath::replaceAll()
- 7.2 QueryPath/QueryPath.php \QueryPath::replaceAll()
File
- QueryPath/
QueryPath.php, line 973
Class
Code
public function replaceAll($selector, DOMDocument $document) {
$replacement = $this
->size() > 0 ? $this
->getFirstMatch() : $this->document
->createTextNode('');
$c = new QueryPathCssEventHandler($document);
$c
->find($selector);
$temp = $c
->getMatches();
foreach ($temp as $item) {
$node = $replacement
->cloneNode();
$node = $document
->importNode($node);
$item->parentNode
->replaceChild($node, $item);
}
return qp($document, NULL, $this->options);
}