XML DOM hasChildNodes()Methods


Element object

Definition and Usage

The hasChildNodes() method returns TRUE if the current element node has child nodes, otherwise it returns FALSE.

Syntax

elementNode.hasChildNodes()


Example

The following code snippet usesloadXMLDoc()put "books.xmlLoad into xmlDoc and check whether the first <book> element has child nodes:

Example

xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName("book")[0];

document.write(x.hasChildNodes());

Output:

true

Try it Yourself »

Element objectother extensions