Easy Tutorial
❮ Met Comment Deletedata Dom Met Nodelist Item ❯

XML DOM getAttributeNS() Method



Definition and Usage

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

Syntax

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 value.

Example

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

Example

xmlDoc = loadXMLDoc("books_ns.xml");

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

document.write(x.getAttributeNS(ns, "lang"));

Output:

cn

❮ Met Comment Deletedata Dom Met Nodelist Item ❯