function Crawler::addNode
Adds a \DOMNode instance to the list of nodes.
Parameters
\DOMNode $node A \DOMNode instance:
3 calls to Crawler::addNode()
- Crawler::add in vendor/
symfony/ dom-crawler/ Crawler.php - Adds a node to the current list of nodes.
- Crawler::addDocument in vendor/
symfony/ dom-crawler/ Crawler.php - Adds a \DOMDocument to the list of nodes.
- Crawler::addNodeList in vendor/
symfony/ dom-crawler/ Crawler.php - Adds a \DOMNodeList to the list of nodes.
File
-
vendor/
symfony/ dom-crawler/ Crawler.php, line 272
Class
- Crawler
- Crawler eases navigation of a list of \DOMNode objects.
Namespace
Symfony\Component\DomCrawlerCode
public function addNode(\DOMNode $node) : void {
if ($node instanceof \DOMDocument) {
$node = $node->documentElement;
}
if (null !== $this->document && $this->document !== $node->ownerDocument) {
throw new \InvalidArgumentException('Attaching DOM nodes from multiple documents in the same crawler is forbidden.');
}
$this->document ??= $node->ownerDocument;
// Don't add duplicate nodes in the Crawler
if (\in_array($node, $this->nodes, true)) {
return;
}
$this->nodes[] = $node;
}