XML DOM getAttributeNS()Methods


Element object

Definition and Usage

The getAttributeNS() method obtains the attribute value by namespace URI and name.

Syntax

elementNode.getAttributeNS(ns,name)

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


Example

The following code snippet usesloadXMLDoc()put "books_ns.xmlIn xmlDoc, create a new <book> node, and get the "lang" attribute value from the first <title> element:

Example

xmlDoc=loadXMLDoc("books_ns.xml"); x=xmlDoc.getElementsByTagName("title")[0]; ns="https://www.example.com/w3cnote/"; document.write(x.getAttributeNS(ns,"lang"));

Output:

cn

Try it Yourself »

Element objectother extensions