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

XML DOM hasAttributeNS() Method

XML DOM hasAttributeNS() Method


Element Object Reference 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 whether an element has an attribute with the specified namespace and name: </p>

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 Reference Element Object