function Crawler::discoverNamespace
Throws
\InvalidArgumentException
1 call to Crawler::discoverNamespace()
- Crawler::createDOMXPath in vendor/
symfony/ dom-crawler/ Crawler.php
File
-
vendor/
symfony/ dom-crawler/ Crawler.php, line 1146
Class
- Crawler
- Crawler eases navigation of a list of \DOMNode objects.
Namespace
Symfony\Component\DomCrawlerCode
private function discoverNamespace(\DOMXPath $domxpath, string $prefix) : ?string {
if (\array_key_exists($prefix, $this->namespaces)) {
return $this->namespaces[$prefix];
}
if ($this->cachedNamespaces
->offsetExists($prefix)) {
return $this->cachedNamespaces[$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));
return $this->cachedNamespaces[$prefix] = ($node = $namespaces->item(0)) ? $node->nodeValue : null;
}