You are here

private function Crawler::discoverNamespace in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dom-crawler/Crawler.php \Symfony\Component\DomCrawler\Crawler::discoverNamespace()

Parameters

\DOMXPath $domxpath:

string $prefix:

Return value

string

Throws

\InvalidArgumentException

1 call to Crawler::discoverNamespace()
Crawler::createDOMXPath in vendor/symfony/dom-crawler/Crawler.php

File

vendor/symfony/dom-crawler/Crawler.php, line 975

Class

Crawler
Crawler eases navigation of a list of \DOMElement objects.

Namespace

Symfony\Component\DomCrawler

Code

private function discoverNamespace(\DOMXPath $domxpath, $prefix) {
  if (isset($this->namespaces[$prefix])) {
    return $this->namespaces[$prefix];
  }

  // ask for one namespace, otherwise we'd get a collection with an item for each node
  $namespaces = $domxpath
    ->query(sprintf('(//namespace::*[name()="%s"])[last()]', $this->defaultNamespacePrefix === $prefix ? '' : $prefix));
  if ($node = $namespaces
    ->item(0)) {
    return $node->nodeValue;
  }
}