DOMElement->hasAttribute()

(no version information, might be only in CVS)

DOMElement->hasAttribute() -- Checks to see if attribute exists

说明

class DOMElement {

bool hasAttribute ( string name )

}

Indicates whether attribute named name exists as a member of the element.

参数

name

The attribute name.

返回值

如果成功则返回 TRUE,失败则返回 FALSE


add a note add a note User Contributed Notes
permidion at yahoo dot com
27-Oct-2004 07:30
simple exemple of use to retrieve all attributes of an element

foreach ($root->childNodes as $child) {
   if ($child->hasAttributes()){
       foreach ($child->attributes as $attribute){
           print "AttributName= ".$attribute->name. "<br/>\n";
           print "AttributValue= ".$attribute->value. "<br/>\n";
       }
   }
}