XML DOM hasChildNodes() method
Definition and usage
The hasChildNodes() method returns true if a node has any child nodes, otherwise it returns false.
Syntax:
nodeObject.hasChildNodes()
Example
In all examples, we will use the XML file books.xml, and the JavaScript function loadXMLDoc().
The following code snippet can return whether the <book> element has any child nodes:
xxmlDoc=loadXMLDoc("books.xml");
var x=xmlDoc.getElementsByTagName("book")[0];
document.write(x.hasChildNodes()
;
Output:
true