public function QueryPath::parent in QueryPath 6
Same name and namespace in other branches
- 7.3 QueryPath/QueryPath.php \QueryPath::parent()
- 7.2 QueryPath/QueryPath.php \QueryPath::parent()
File
- QueryPath/
QueryPath.php, line 1095
Class
Code
public function parent($selector = NULL) {
$found = new SplObjectStorage();
foreach ($this->matches as $m) {
while ($m->parentNode->nodeType !== XML_DOCUMENT_NODE) {
$m = $m->parentNode;
if ($m->nodeType === XML_ELEMENT_NODE) {
if (!empty($selector)) {
if (qp($m, NULL, $this->options)
->is($selector) > 0) {
$found
->attach($m);
break;
}
}
else {
$found
->attach($m);
break;
}
}
}
}
$this
->setMatches($found);
return $this;
}