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

XML DOM getAttributeNodeNS() Method

XML DOM getAttributeNodeNS() Method


Element Object Reference Element Object


Definition and Usage

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

Syntax

elementNode.getAttributeNodeNS(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" Load into xmlDoc, and from the first get the "lang" attribute node from an element: </p>

Example

xmlDoc

=

loadXMLDoc

(

"

books_ns.xml

"

)

;

x

=

xmlDoc

.

getElementsByTagName

(

"

title

"

)

[

0

]

;

ns

=

"

http://www.runoob.com/w3cnote/

"

;

y

=

x

.

getAttributeNodeNS

(

ns

,

"

lang

"

)

;

document

.

write

(

y

.

nodeName

)

;

document

.

write

(

"

=

"

)

;

document

.

write

(

y

.

nodeValue

)

;

Output:

c:lang = cn

Try it »


Element Object Reference Element Object