public function QueryPath::unwrap in QueryPath 6
Same name and namespace in other branches
- 7.3 QueryPath/QueryPath.php \QueryPath::unwrap()
- 7.2 QueryPath/QueryPath.php \QueryPath::unwrap()
File
- QueryPath/
QueryPath.php, line 734
Class
Code
public function unwrap() {
$parents = new SplObjectStorage();
foreach ($this->matches as $m) {
if ($m
->isSameNode($m->ownerDocument->documentElement)) {
throw new QueryPathException('Cannot unwrap the root element.');
}
$parent = $m->parentNode;
$old = $parent
->removeChild($m);
$parent->parentNode
->insertBefore($old, $parent);
$parents
->attach($parent);
}
foreach ($parents as $ele) {
$ele->parentNode
->removeChild($ele);
}
return $this;
}