Easy Tutorial
❮ Prop Element Firstchild Dom Met Document Renamenode ❯

XML DOM getAttributeNodeNS() Method



Definition and Usage

The getAttributeNS() method retrieves an attribute node by namespace URI and name.

Syntax

Parameter Description
ns Required. Specifies the namespace URI from which to retrieve the attribute value.
name Required. Specifies the attribute from which to retrieve the value.

Example

The following code snippet uses loadXMLDoc() to load "books_ns.xml" into xmlDoc and retrieves the "lang" attribute node from the first <title> element:

Example

xmlDoc=loadXMLDoc("books_ns.xml");

x=xmlDoc.getElementsByTagName("title")[0];
ns="http://www.tutorialpro.org/w3cnote/";

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

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

Output:

c:lang = cn

❮ Prop Element Firstchild Dom Met Document Renamenode ❯