XML DOM getAttributeNodeNS() Method
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
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