XML DOM getAttributeNS () method
Definition and Usage
getAttributeNS () method to obtain the property value by namespace URI and name.
grammar
elementNode.getAttributeNS(ns,name)
参数 | 描述 |
---|---|
ns | 必需。规定从中获取属性值的命名空间 URI。 |
name | 必需。规定从中获取属性值的属性。 |
Examples
The following code fragment uses loadXMLDoc () to " books_ns.xml " into xmlDoc create a new <book> node, and achieved "lang" attribute from the first <title> element:
Examples
xmlDoc=loadXMLDoc("books_ns.xml");
x=xmlDoc.getElementsByTagName("title")[0];
ns="http://www.w3schools.com/children/";
document.write(x.getAttributeNS(ns,"lang"));
x=xmlDoc.getElementsByTagName("title")[0];
ns="http://www.w3schools.com/children/";
document.write(x.getAttributeNS(ns,"lang"));
Output:
en
try it"
Element object