Easy Tutorial
❮ Prop Attr Nodevalue Dom Met Node Haschildnodes ❯

XML DOM hasAttribute() Method



Definition and Usage

The hasAttribute() method returns TRUE if the current element node has an attribute with the specified name, otherwise it returns FALSE.

Syntax

Parameter Description
name Required. Specifies the attribute to look for.

Example

The following code snippet uses loadXMLDoc() to load "books.xml" into xmlDoc and checks if the first <book> element has a "category" attribute:

Example

Output:

❮ Prop Attr Nodevalue Dom Met Node Haschildnodes ❯