XML DOM getAttributeNodeNS()Methods
Element object
Definition and Usage
The getAttributeNS() method obtains an attribute node by namespace URI and name.
Syntax
elementNode.getAttributeNodeNS(ns,name)
| Parameter | Description |
|---|---|
| ns | Required. Specifies the namespace URI from which to obtain the attribute value. |
| name | Required. Specifies the attribute from which to obtain the attribute value. |
Example
The following code snippet usesloadXMLDoc()put "books_ns.xml" Load into xmlDoc, and get the "lang" attribute node from the first <title> element:
Example
xmlDoc=loadXMLDoc("books_ns.xml");
x=xmlDoc.getElementsByTagName("title")[0];
ns="http://www.example.com/w3cnote/";
y=x.getAttributeNodeNS(ns,"lang");
document.write(y.nodeName);
document.write(" = ");
document.write(y.nodeValue);
Output:
c:lang = cn
Try it Yourself »
Element objectother extensions