QueryPath\CSS\DOMTraverser\Util::matchesAttributeNS PHP Method

matchesAttributeNS() public static method

Check whether the given DOMElement has the given namespaced attribute.
public static matchesAttributeNS ( $node, $name, $nsuri, $value = null, $operation = EventHandler::isExactly )
    public static function matchesAttributeNS($node, $name, $nsuri, $value = null, $operation = EventHandler::isExactly)
    {
        if (!$node->hasAttributeNS($nsuri, $name)) {
            return false;
        }
        if (is_null($value)) {
            return true;
        }
        return self::matchesAttributeValue($value, $node->getAttributeNS($nsuri, $name), $operation);
    }

Usage Example

Example #1
0
 /**
  * Pseudo-class handler for :lang
  *
  * Note that this does not implement the spec in its entirety because we do
  * not presume to "know the language" of the document. If anyone is interested
  * in making this more intelligent, please do so.
  */
 protected function lang($node, $value)
 {
     // TODO: This checks for cases where an explicit language is
     // set. The spec seems to indicate that an element should inherit
     // language from the parent... but this is unclear.
     $operator = strpos($value, '-') !== FALSE ? EventHandler::isExactly : EventHandler::containsWithHyphen;
     $match = TRUE;
     foreach ($node->attributes as $attrNode) {
         if ($attrNode->localName == 'lang') {
             if ($attrNode->nodeName == $attrNode->localName) {
                 // fprintf(STDOUT, "%s in NS %s\n", $attrNode->name, $attrNode->nodeName);
                 return Util::matchesAttribute($node, 'lang', $value, $operator);
             } else {
                 $nsuri = $attrNode->namespaceURI;
                 // fprintf(STDOUT, "%s in NS %s\n", $attrNode->name, $nsuri);
                 return Util::matchesAttributeNS($node, 'lang', $nsuri, $value, $operator);
             }
         }
     }
     return FALSE;
 }
All Usage Examples Of QueryPath\CSS\DOMTraverser\Util::matchesAttributeNS