You are here

public function QueryPath::children in QueryPath 6

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

File

QueryPath/QueryPath.php, line 1024

Class

QueryPath

Code

public function children($selector = NULL) {
  $found = new SplObjectStorage();
  foreach ($this->matches as $m) {
    foreach ($m->childNodes as $c) {
      if ($c->nodeType == XML_ELEMENT_NODE) {
        $found
          ->attach($c);
      }
    }
  }
  if (empty($selector)) {
    $this
      ->setMatches($found);
  }
  else {
    $this->matches = $found;
    $this
      ->filter($selector);
  }
  return $this;
}