XML DOM hasChildNodes() Method
Complete Element Object Reference
Definition and Usage
The hasChildNodes() method returns TRUE if the current element node has child
nodes, and FALSE otherwise.
Syntax
elementNode.hasChildNodes()
|
Example
The following code fragment loads "books.xml"
into xmlDoc using
loadXMLDoc() and checks if the first <book> element
has any child nodes:
xxmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName("book")[0];
document.write(x.hasChildNodes());
|
Output:
Try-It-Yourself Demos
hasChildNodes() - Checks if an element has child nodes
Complete Element Object Reference
Learn XML with <oXygen/> XML Editor - Free Trial!
|
|
oXygen helps you learn to define,
edit, validate and transform XML documents. Supported technologies include XML Schema,
DTD, Relax NG, XSLT, XPath, XQuery, CSS.
Understand in no time how XSLT and XQuery work by using the intuitive oXygen debugger!
Do you have any XML related questions? Get free answers from the oXygen
XML forum
and from the video
demonstrations.
Download a FREE 30-day trial today!
|
|