/** * @method query * @param string $expression * Query the remaining HTML. * @return array */ public function query($expression) { // Any child XPath expressions mustn't be prepended with "//", but it's a common mistake, so // remove them. $expression = str_replace('//', '', $expression); // Find the nodes based on the expression that was passed in. $xpath = new DOMXPath($this->_dom); $nodes = $xpath->query($expression, $this->_item); // Package all of the obtained nodes into their XPathDocument_Dom equivalents. $package = new XPathDocument_Dom_Package($nodes, $this->_dom); return $package->getItems(); }
/** * @method query * @param str * @param string $expression * Perform an XPath query on the current DOMDocument. * @throws Exception * @return XPathDocument_Dom_List */ public function query($expression) { // Find the nodes based on the expression that was passed in. $xpath = new DOMXPath($this->_dom); $nodes = @$xpath->query($expression); if (!$nodes) { throw new Exception(sprintf('Invalid expression: "%s"', $expression)); } // Package all of the obtained nodes into their XPathDocument equivalents. $package = new XPathDocument_Dom_Package($nodes, $this->_dom); return $package->getItems(); }