Symfony\Component\DomCrawler\Crawler::add PHP Method

add() public method

This method uses the appropriate specialized add*() method based on the type of the argument.
public add ( DOMNodeList | DOMNode | array | string | null $node )
$node DOMNodeList | DOMNode | array | string | null A node
    public function add($node)
    {
        if ($node instanceof \DOMNodeList) {
            $this->addNodeList($node);
        } elseif ($node instanceof \DOMNode) {
            $this->addNode($node);
        } elseif (is_array($node)) {
            $this->addNodes($node);
        } elseif (is_string($node)) {
            $this->addContent($node);
        } elseif (null !== $node) {
            throw new \InvalidArgumentException(sprintf('Expecting a DOMNodeList or DOMNode instance, an array, a string, or null, but got "%s".', is_object($node) ? get_class($node) : gettype($node)));
        }
    }

Usage Example

Ejemplo n.º 1
0
 public function call($uri, $method = 'get', $parameters = array(), $changeStack = true)
 {
     $browser = parent::call($uri, $method, $parameters, $changeStack);
     $crawler = new Crawler();
     $crawler->add($browser->getResponse()->getContent());
     return $crawler;
 }
All Usage Examples Of Symfony\Component\DomCrawler\Crawler::add