QueryPath\CSS\DOMTraverser::matchElement PHP Method

matchElement() protected method

This handles the following cases: - element (foo) - namespaced element (ns|foo) - namespaced wildcard (ns|*) - wildcard (* or *|*)
protected matchElement ( $node, $element, $ns = null )
    protected function matchElement($node, $element, $ns = null)
    {
        if (empty($element)) {
            return true;
        }
        // Handle namespace.
        if (!empty($ns) && $ns != '*') {
            // Check whether we have a matching NS URI.
            $nsuri = $node->lookupNamespaceURI($ns);
            if (empty($nsuri) || $node->namespaceURI !== $nsuri) {
                return false;
            }
        }
        // Compare local name to given element name.
        return $element == '*' || $node->localName == $element;
    }