You are here

public function QueryPath::firstChild in QueryPath 6

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

File

QueryPath/QueryPath.php, line 1692

Class

QueryPath

Code

public function firstChild() {
  $found = new SplObjectStorage();
  $flag = false;
  foreach ($this->matches as $m) {
    foreach ($m->childNodes as $c) {
      if ($c->nodeType == XML_ELEMENT_NODE) {
        $found
          ->attach($c);
        $flag = true;
        break;
      }
    }
    if ($flag) {
      break;
    }
  }
  $this
    ->setMatches($found);
  $this->matches = $found;
  return $this;
}