XML DOM hasAttributeNS()Methods
Element object
Definition and Usage
The hasAttributeNS() method returns TRUE if the current element node has an attribute matching the specified namespace and name; otherwise, it returns FALSE.
Syntax
hasAttributeNS(ns,name)
| Parameter | Description |
|---|---|
| ns | Required. Specifies the namespace of the attribute to find. |
| name | Required. Specifies the name of the attribute to find. |
Example
The following code snippet usesloadXMLDoc()put "books_ns.xml" Load into xmlDoc, and check whether the first <title> element has an attribute with the specified namespace and name:
Example
xmlDoc=loadXMLDoc("books_ns.xml");
x=xmlDoc.getElementsByTagName("title")[0];
ns="http://www.example.com/w3cnote/";
document.write(x.hasAttributeNS(ns,"lang"));
Output:
true
Try it Yourself »
Element objectother extensions