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


Element Object Reference Element Object


Definition and Usage

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

Syntax

elementNode.hasChildNodes()


Example

The following code snippet uses loadXMLDoc() to load "books.xml" into xmlDoc, and check 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 »


Element Object Reference Element Object