FluentDOM\Nodes\Builder::getTargetNodes PHP Method

getTargetNodes() public method

Match selector against context and return matched elements.
public getTargetNodes ( mixed $selector, DOMNode $context = NULL ) : array
$selector mixed
$context DOMNode optional, default value NULL
return array
    public function getTargetNodes($selector, \DOMNode $context = NULL)
    {
        if ($nodes = $this->getNodeList($selector)) {
            return $nodes;
        } elseif (is_string($selector)) {
            $result = $this->getOwner()->xpath($this->getOwner()->prepareSelector($selector, Nodes::CONTEXT_SELF), $context);
            if (!$result instanceof \Traversable) {
                throw new \InvalidArgumentException('Given selector did not return an node list.');
            }
            return iterator_to_array($result);
        }
        throw new \InvalidArgumentException('Invalid selector');
    }