XML DOM hasAttributeNS() Method
Element Object
Definition and Usage
The hasAttributeNS() method returns TRUE when the current element node has an attribute matching the specified namespace and name, otherwise it returns FALSE.
Syntax
hasAttributeNS(ns,name)
| Parameters | Description |
|---|---|
| ns | Required. Specifies the namespace of the attribute to look for. |
| name | Required. Specifies the name of the attribute to look for. |
Example
The following code snippet uses loadXMLDoc() to load "books_ns.xml" into xmlDoc, and check whether the first
Example
xmlDoc
=
loadXMLDoc
(
"
books_ns.xml
"
)
;
x
=
xmlDoc
.
getElementsByTagName
(
"
title
"
)
[
0
]
;
ns
=
"
http://www.runoob.com/w3cnote/
"
;
document
.
write
(
x
.
hasAttributeNS
(
ns
,
"
lang
"
)
)
;
Output:
true
Try it »
Element Object