You are here

public function QueryPath::prevUntil in QueryPath 6

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

File

QueryPath/QueryPath.php, line 1774

Class

QueryPath

Code

public function prevUntil($selector = NULL) {
  $found = new SplObjectStorage();
  foreach ($this->matches as $m) {
    while (isset($m->previousSibling)) {
      $m = $m->previousSibling;
      if ($m->nodeType === XML_ELEMENT_NODE) {
        if (!empty($selector) && qp($m, NULL, $this->options)
          ->is($selector)) {
          break;
        }
        else {
          $found
            ->attach($m);
        }
      }
    }
  }
  $this
    ->setMatches($found);
  return $this;
}