find() public méthode

This is the main function for querying the DOM using a CSS selector.
public find ( string $selector )
$selector string The selector.
Exemple #1
0
 public function findInPlace($selector)
 {
     $query = new \QueryPath\CSS\DOMTraverser($this->matches);
     $query->find($selector);
     $this->setMatches($query->matches());
     return $this;
 }
 /**
  * Get the children of the elements in the DOMQuery object.
  *
  * If a selector is provided, the list of children will be filtered through
  * the selector.
  *
  * @param string $selector
  *  A valid selector.
  * @return \QueryPath\DOMQuery
  *  A DOMQuery wrapping all of the children.
  * @see removeChildren()
  * @see parent()
  * @see parents()
  * @see next()
  * @see prev()
  */
 public function children($selector = NULL)
 {
     $found = new \SplObjectStorage();
     $filter = strlen($selector) > 0;
     if ($filter) {
         $tmp = new \SplObjectStorage();
     }
     foreach ($this->matches as $m) {
         foreach ($m->childNodes as $c) {
             if ($c->nodeType == XML_ELEMENT_NODE) {
                 // This is basically an optimized filter() just for children().
                 if ($filter) {
                     $tmp->attach($c);
                     $query = new \QueryPath\CSS\DOMTraverser($tmp, TRUE, $c);
                     $query->find($selector);
                     if (count($query->matches()) > 0) {
                         $found->attach($c);
                     }
                     $tmp->detach($c);
                 } else {
                     $found->attach($c);
                 }
             }
         }
     }
     $new = $this->inst($found, NULL, $this->options);
     return $new;
 }