You are here

protected function DOMXPath::executeQuery in Feeds XPath Parser 8

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.

Overrides DOMXPath::executeQuery

1 call to DOMXPath::executeQuery()
DOMXPath::namespacedQuery in lib/Drupal/feeds_xpathparser/DOMXPath.php
Executes an XPath query with namespace support.
1 method overrides DOMXPath::executeQuery()
DOMXPath::executeQuery in lib/Drupal/feeds_xpathparser/DOMXPath.php
Performs a XPath query.

File

lib/Drupal/feeds_xpathparser/DOMXPath.php, line 204
Contains \Druapl\feeds_xpathparser\DOMXPath.

Class

DOMXPath
Wraps DOMXPath providing enhanced debugging and special namespace handling.

Namespace

Drupal\feeds_xpathparser

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;
}