Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XML DOM getAttributeNS() Method

XML DOM getAttributeNS() Method


Element Object Reference Element Object


Definition and Usage

The getAttributeNS() method gets an attribute value by namespace URI and name.

Syntax

elementNode.getAttributeNS(ns,name)

Parameters Description
ns Required. Specifies the namespace URI from which to get 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, create a new node, and from the first element get the "lang" attribute value: </p>

Example

xmlDoc

=

loadXMLDoc

(

"

books_ns.xml

"

)

;

x

=

xmlDoc

.

getElementsByTagName

(

"

title

"

)

[

0

]

;

ns

=

"

https://www.runoob.com/w3cnote/

"

;

document

.

write

(

x

.

getAttributeNS

(

ns

,

"

lang

"

)

)

;

Output:

cn

Try it »


Element Object Reference Element Object