You are here

public function QueryPath::lastChild in QueryPath 6

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

File

QueryPath/QueryPath.php, line 1729

Class

QueryPath

Code

public function lastChild() {
  $found = new SplObjectStorage();
  $item = null;
  foreach ($this->matches as $m) {
    foreach ($m->childNodes as $c) {
      if ($c->nodeType == XML_ELEMENT_NODE) {
        $item = $c;
      }
    }
    if ($item) {
      $found
        ->attach($item);
      $item = null;
    }
  }
  $this
    ->setMatches($found);
  $this->matches = $found;
  return $this;
}