Crawler.php
public function evaluate($xpath)
    {
        if (null === $this->document) {
            throw new \LogicException('Cannot evaluate the expression on an uninitialized crawler.');
        }

        $data = array();
        $domxpath = $this->createDOMXPath($this->document, $this->findNamespacePrefixes($xpath));

        foreach ($this->nodes as $node) {
            $data[] = $domxpath->evaluate($xpath, $node);
        }

        if (isset($data[0]) && $data[0] instanceof \DOMNodeList) {
            return $this->createSubCrawler($data);
        }

        return $data;
    }
public function evaluate($xpath)
    {
        if (null === $this->document) {
            throw new \LogicException('Cannot evaluate the expression on an uninitialized crawler.');
        }

        $data = array();
        $domxpath = $this->createDOMXPath($this->document, $this->findNamespacePrefixes($xpath));

        foreach ($this->nodes as $node) {
            $data[] = $domxpath->evaluate($xpath, $node);
        }

        if (isset($data[0]) && $data[0] instanceof \DOMNodeList) {
            return $this->createSubCrawler($data);
        }

        return $data;
    }
public function evaluate ( $ xpath ) { if ( null === $ this -> document ) { throw new \ LogicException ( 'Cannot evaluate the expression on an uninitialized crawler.' ) ; } $ data = array ( ) ; $ domxpath = $ this -> createDOMXPath ( $ this -> document , $ this -> findNamespacePrefixes ( $ xpath ) ) ; foreach ( $ this -> nodes as $ node ) { $ data [ ] = $ domxpath -> evaluate ( $ xpath , $ node ) ; } if ( isset ( $ data [ 0 ] ) && $ data [ 0 ] instanceof \ DOMNodeList ) { return $ this -> createSubCrawler ( $ data ) ; } return $ data ; }
Evaluates an XPath expression.

Since an XPath expression might evaluate to either a simple type or a \DOMNodeList,
this method will return either an array of simple types or a new Crawler instance.

@param string $xpath An XPath expression

@return array|Crawler An array of evaluation results or a new Crawler instance
Evaluates an XPath expression .