public function children($selector=null)
    {
        $result = $this->createChildInstance();

        if (isset($this->document) && $this->length > 0) {
            if (isset($this->root_instance) || $this->getXpathQuery()) {
                foreach ($this->nodes as $node) {
                    if ($node->hasChildNodes()) {
                        $result->loadDomNodeList($node->childNodes);
                    }
                }
            } else {
                $result->loadDomNodeList($this->document->childNodes);
            }

            if ($selector !== false) { // filter out text nodes
                $filtered_elements = array();
                foreach ($result->getElements() as $result_elm) {
                    $filtered_elements[] = $result_elm;
                }
                $result->nodes = $filtered_elements;
                $result->length = \count($result->nodes);
            }

            if ($selector) {
                $result = $result->filter($selector);
            }
        }

        return $result;
    }
public function children($selector=null)
    {
        $result = $this->createChildInstance();

        if (isset($this->document) && $this->length > 0) {
            if (isset($this->root_instance) || $this->getXpathQuery()) {
                foreach ($this->nodes as $node) {
                    if ($node->hasChildNodes()) {
                        $result->loadDomNodeList($node->childNodes);
                    }
                }
            } else {
                $result->loadDomNodeList($this->document->childNodes);
            }

            if ($selector !== false) { // filter out text nodes
                $filtered_elements = array();
                foreach ($result->getElements() as $result_elm) {
                    $filtered_elements[] = $result_elm;
                }
                $result->nodes = $filtered_elements;
                $result->length = \count($result->nodes);
            }

            if ($selector) {
                $result = $result->filter($selector);
            }
        }

        return $result;
    }
public function children ( $ selector = null ) { $ result = $ this -> createChildInstance ( ) ; if ( isset ( $ this -> document ) && $ this -> length > 0 ) { if ( isset ( $ this -> root_instance ) || $ this -> getXpathQuery ( ) ) { foreach ( $ this -> nodes as $ node ) { if ( $ node -> hasChildNodes ( ) ) { $ result -> loadDomNodeList ( $ node -> childNodes ) ; } } } else { $ result -> loadDomNodeList ( $ this -> document -> childNodes ) ; } if ( $ selector !== false ) { // filter out text nodes $ filtered_elements = array ( ) ; foreach ( $ result -> getElements ( ) as $ result_elm ) { $ filtered_elements [ ] = $ result_elm ; } $ result -> nodes = $ filtered_elements ; $ result -> length = \ count ( $ result -> nodes ) ; } if ( $ selector ) { $ result = $ result -> filter ( $ selector ) ; } } return $ result ; }
Get the children of each element in the set of matched elements, optionally filtered by a selector.

@param string|self|callable|\DOMNodeList|\DOMNode|false|null $selector expression that filters the set of matched elements

@return self
Get the children of each element in the set of matched elements optionally filtered by a selector .