protected function FeedsXPathParserDOMXPath::executeQuery in Feeds XPath Parser 7
Same name and namespace in other branches
- 6 FeedsXPathParserDOMXPath.inc \FeedsXPathParserDOMXPath::executeQuery()
Performs a XPath query.
Here we set libxml_use_internal_errors() to TRUE because depending on the libxml version, $xml->xpath() might return FALSE or an empty array() when a query doesn't match.
Parameters
string $query: The XPath query string.
DOMNode $context: (optional) A context object. Defaults to NULL.
Return value
mixed The result of the XPath query.
1 call to FeedsXPathParserDOMXPath::executeQuery()
- FeedsXPathParserDOMXPath::namespacedQuery in ./
FeedsXPathParserDOMXPath.inc - Executes an XPath query with namespace support.
File
- ./
FeedsXPathParserDOMXPath.inc, line 202 - Provides a custom version of DOMXPath for use with feeds_xpathparser.
Class
- FeedsXPathParserDOMXPath
- Wraps DOMXPath providing enhanced debugging and special namespace handling.
Code
protected function executeQuery($query, DOMNode $context = NULL) {
$use_errors = libxml_use_internal_errors(TRUE);
// Perfom XPath query.
// So, grrr. FALSE is returned when there is an error. However, FALSE is
// also a valid return value from DOMXPath::evaluate(). Ex: '1 = 2'
if ($context) {
$results = $this
->evaluate($query, $context);
}
else {
$results = $this
->query($query);
}
$this->error = libxml_get_last_error();
libxml_clear_errors();
libxml_use_internal_errors($use_errors);
return $results;
}