You are here

protected function Xml::registerNamespaces in Views XML Backend 8

Registers available namespaces.

Parameters

\DOMXPath $xpath: The XPath object.

1 call to Xml::registerNamespaces()
Xml::getXpath in src/Plugin/views/query/Xml.php
Returns the XPath object for this query.

File

src/Plugin/views/query/Xml.php, line 712
Contains \Drupal\views_xml_backend\Plugin\views\query\Xml.

Class

Xml
Views query plugin for an XML query.

Namespace

Drupal\views_xml_backend\Plugin\views\query

Code

protected function registerNamespaces(\DOMXPath $xpath) {
  $xpath
    ->registerNamespace('php', 'http://php.net/xpath');
  if (!($simple = @simplexml_import_dom($xpath->document))) {
    return;
  }
  foreach ($simple
    ->getNamespaces(TRUE) as $prefix => $namespace) {
    if ($prefix === '') {
      $prefix = $this->options['default_namespace'];
    }
    $xpath
      ->registerNamespace($prefix, $namespace);
  }
}