FluentDOM\Xpath::firstOf PHP Method

firstOf() public method

Returns the first node matched by the expression or NULL.
public firstOf ( string $expression, DOMNode $contextNode = NULL, null | boolean $registerNodeNS = NULL ) : DOMNode | null
$expression string
$contextNode DOMNode
$registerNodeNS null | boolean
return DOMNode | null
    public function firstOf($expression, \DOMNode $contextNode = NULL, $registerNodeNS = NULL)
    {
        $nodes = $this->evaluate($expression, $contextNode, $registerNodeNS);
        if ($nodes instanceof \DOMNodeList && $nodes->length > 0) {
            return $nodes->item(0);
        }
        return NULL;
    }