XML DOM hasChildNodes() Method
Complete Node Object Reference
Definition and Usage
The hasChildNodes() method returns true if a node has any child
nodes, otherwise it returns false.
Syntax
nodeObject.hasChildNodes()
|
Example
The following code fragment loads "books.xml"
into xmlDoc using
loadXMLDoc() and returns whether the first <book> element has any
child nodes:
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName("book")[0];
document.write(x.hasChildNodes());
|
Output:
Try-It-Yourself Demos
hasChildNodes() - Checks if an element has any child nodes
Complete Node Object Reference
Whether you're new to XML or already an advanced user, the user-friendly views
and powerful entry helpers, wizards, and debuggers in XMLSpy are designed to
meet your XML and Web services development needs from start to finish.
- XML editor
- Graphical XML Schema / DTD editors
- XSLT 1.0/2.0 editor, debugger, profiler
- XQuery editor, debugger, profiler
- Support for Office Open XML (OOXML)
- Graphical WSDL editor & SOAP debugger
- Java, C#, C++ code generation
- And much more!
Download a free 30-day trial today!
|