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