Latest web development tutorials

XML DOM getAttributeNodeNS () method

Element Object Reference Element object

Definition and Usage

getAttributeNS () method to obtain an attribute node by name and namespace URI.

grammar

elementNode.getAttributeNodeNS(ns,name)

参数 描述
ns 必需。规定从中获取属性值的命名空间 URI。
name 必需。规定从中获取属性值的属性。


Examples

The following code fragment uses loadXMLDoc () to " books_ns.xml " into xmlDoc and made "lang" attribute nodes from the first <title> element:

Examples

xmlDoc=loadXMLDoc("books_ns.xml");

x=xmlDoc.getElementsByTagName("title")[0];
ns="http://www.w3cschool.cc/children/";

y=x.getAttributeNodeNS(ns,"lang");

document.write(y.nodeName);
document.write(" = ");
document.write(y.nodeValue);

Output:

c:lang = en

try it"

Element Object Reference Element object