public function DOMXPath::namespacedQuery in Feeds XPath Parser 8
Executes an XPath query with namespace support.
Parameters
string $query: An XPath query.
string $source: The source key for this query.
\DOMNode $context: (optional) The current context of the XPath query. Defaults to null.
Return value
array An array containing the results of the query.
Overrides DOMXPath::namespacedQuery
1 method overrides DOMXPath::namespacedQuery()
- DOMXPath::namespacedQuery in lib/
Drupal/ feeds_xpathparser/ DOMXPath.php - Executes an XPath query with namespace support.
File
- lib/
Drupal/ feeds_xpathparser/ DOMXPath.php, line 118 - Contains \Druapl\feeds_xpathparser\DOMXPath.
Class
- DOMXPath
- Wraps DOMXPath providing enhanced debugging and special namespace handling.
Namespace
Drupal\feeds_xpathparserCode
public function namespacedQuery($query, $source, \DOMNode $context = NULL) {
$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;
}