You are here

public function QueryPath::replaceAll in QueryPath 7.2

Same name and namespace in other branches
  1. 6 QueryPath/QueryPath.php \QueryPath::replaceAll()
  2. 7.3 QueryPath/QueryPath.php \QueryPath::replaceAll()

File

QueryPath/QueryPath.php, line 973

Class

QueryPath

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);
}