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

XML DOM hasChildNodes() Method

XML DOM hasChildNodes() Method


Node Object Reference Node object


Definition and Usage

The hasChildNodes() method returns true if the node has any child nodes, otherwise it returns false.

Syntax

nodeObject.hasChildNodes()


Example

The following code snippet uses loadXMLDoc() to load "books.xml" into xmlDoc, and return whether the first whether the element has any child nodes:

Example

xmlDoc=loadXMLDoc("books.xml");

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

document.write(x.hasChildNodes());

Output:

true

Try it »


Node Object Reference Node object