XML DOM hasChildNodes() Method
Definition and Usage
If the current element node has child nodes, hasChildNodes() returns true, otherwise it returns false.
Syntax:
elementNode.hasChildNodes()
Example
In all examples, we will use the XML file books.xml, and JavaScript function loadXMLDoc().
The following code snippet checks if the first <book> element in "books.xml" has child nodes:
xxmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName("book")[0];
document.write(x.hasChildNodes()
);
The output of the above code is:
true