public function FeedsXPathParserDOMXPath::namespacedQuery in Feeds XPath Parser 6
Same name and namespace in other branches
- 7 FeedsXPathParserDOMXPath.inc \FeedsXPathParserDOMXPath::namespacedQuery()
Executes an XPath query with namespace support.
Parameters
string $query: An XPath query.
DOMNode $context: The current context of the XPath query.
string $source: The source key for this query.
Return value
array An array containing the results of the query.
File
- ./
FeedsXPathParserDOMXPath.inc, line 78 - Provides a custom version of DOMXPath for use with feeds_xpathparser.
Class
- FeedsXPathParserDOMXPath
- Wraps DOMXPath providing enhanced debugging and special namespace handling.
Code
public function namespacedQuery($query, $context, $source) {
$this
->addDefaultNamespace($query);
$results = $this
->executeQuery($query, $context);
if (in_array($source, $this->config['debug'])) {
$this
->debug($results, $source);
}
if (is_object($this->error) && $this->config['errors']) {
if ($this->error->level == LIBXML_ERR_ERROR) {
drupal_set_message(t('There was an error during the XPath query: %query.<br />Libxml returned the message: %message, with the error code: %code.', array(
'%query' => $query,
'%message' => trim($this->error->message),
'%code' => $this->error->code,
)), 'error', FALSE);
}
elseif ($this->error->level == LIBXML_ERR_WARNING) {
drupal_set_message(t('There was an error during the XPath query: %query.<br />Libxml returned the message: %message, with the error code: %code.', array(
'%query' => $query,
'%message' => trim($this->error->message),
'%code' => $this->error->code,
)), 'warning', FALSE);
}
}
// DOMXPath::evaluate() and DOMXPath::query() will return FALSE on error or
// if the value is false. We check error result and return NULL in case
// of error.
if (is_object($this->error) && $this->error->level == LIBXML_ERR_ERROR) {
return NULL;
}
return $results;
}