XML DOM hasChildNodes()Methods


Node object

Definition and Usage

The hasChildNodes() method returns true when a node has child nodes, otherwise it returns false.

Syntax

nodeObject.hasChildNodes()


Example

The following code snippet usesloadXMLDoc()put "books.xmlLoad into xmlDoc and return 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 »

Node objectother extensions