XML DOM hasChildNodes () method
Definition and Usage
hasChildNodes () method returns true when the node has a child node, otherwise it returns false.
grammar
nodeObject.hasChildNodes()
Examples
The following code fragment uses loadXMLDoc () to " the Books.xml " into xmlDoc, and returns the first <book> element has child nodes if:
Examples
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName("book")[0];
document.write(x.hasChildNodes());
x=xmlDoc.getElementsByTagName("book")[0];
document.write(x.hasChildNodes());
Output:
true
try it"
Node objects