public static function xpQuery(DOMNode $node, string $query) : array
    {
        static $xpCache = null;

        if ($node instanceof DOMDocument) {
            $doc = $node;
        } else {
            $doc = $node->ownerDocument;
        }

        if ($xpCache === null || !$xpCache->document->isSameNode($doc)) {
            $xpCache = new DOMXPath($doc);
            $xpCache->registerNamespace('soap-env', Constants::NS_SOAP);
            $xpCache->registerNamespace('saml_protocol', Constants::NS_SAMLP);
            $xpCache->registerNamespace('saml_assertion', Constants::NS_SAML);
            $xpCache->registerNamespace('saml_metadata', Constants::NS_MD);
            $xpCache->registerNamespace('ds', XMLSecurityDSig::XMLDSIGNS);
            $xpCache->registerNamespace('xenc', XMLSecEnc::XMLENCNS);
        }

        $results = $xpCache->query($query, $node);
        $ret = [];
        for ($i = 0; $i < $results->length; $i++) {
            $ret[$i] = $results->item($i);
        }

        return $ret;
    }
public static function xpQuery(DOMNode $node, string $query) : array
    {
        static $xpCache = null;

        if ($node instanceof DOMDocument) {
            $doc = $node;
        } else {
            $doc = $node->ownerDocument;
        }

        if ($xpCache === null || !$xpCache->document->isSameNode($doc)) {
            $xpCache = new DOMXPath($doc);
            $xpCache->registerNamespace('soap-env', Constants::NS_SOAP);
            $xpCache->registerNamespace('saml_protocol', Constants::NS_SAMLP);
            $xpCache->registerNamespace('saml_assertion', Constants::NS_SAML);
            $xpCache->registerNamespace('saml_metadata', Constants::NS_MD);
            $xpCache->registerNamespace('ds', XMLSecurityDSig::XMLDSIGNS);
            $xpCache->registerNamespace('xenc', XMLSecEnc::XMLENCNS);
        }

        $results = $xpCache->query($query, $node);
        $ret = [];
        for ($i = 0; $i < $results->length; $i++) {
            $ret[$i] = $results->item($i);
        }

        return $ret;
    }
public static function xpQuery ( DOMNode $ node , string $ query ) : array { static $ xpCache = null ; if ( $ node instanceof DOMDocument ) { $ doc = $ node ; } else { $ doc = $ node -> ownerDocument ; } if ( $ xpCache === null || ! $ xpCache -> document -> isSameNode ( $ doc ) ) { $ xpCache = new DOMXPath ( $ doc ) ; $ xpCache -> registerNamespace ( 'soap-env' , Constants :: NS_SOAP ) ; $ xpCache -> registerNamespace ( 'saml_protocol' , Constants :: NS_SAMLP ) ; $ xpCache -> registerNamespace ( 'saml_assertion' , Constants :: NS_SAML ) ; $ xpCache -> registerNamespace ( 'saml_metadata' , Constants :: NS_MD ) ; $ xpCache -> registerNamespace ( 'ds' , XMLSecurityDSig :: XMLDSIGNS ) ; $ xpCache -> registerNamespace ( 'xenc' , XMLSecEnc :: XMLENCNS ) ; } $ results = $ xpCache -> query ( $ query , $ node ) ; $ ret = [ ] ; for ( $ i = 0 ; $ i < $ results -> length ; $ i ++ ) { $ ret [ $ i ] = $ results -> item ( $ i ) ; } return $ ret ; }
Do an XPath query on an XML node.

@param \DOMNode $node  The XML node.
@param string $query The query.
@return \DOMNode[] Array with matching DOM nodes.
Do an XPath query on an XML node .