getChildNodes (DOMNode - JavaScript)

Gets a list of the children of a node.

Defined in

DOMNode

Syntax

getChildNodes() : DOMNodeList

Return value Description
DOMNodeList The child nodes.

Usage

If there are no child nodes, the length of the list is 0. See getLength.

Examples

This button gets the child nodes below the schema level of a DOM where requestScope.n is the location of a document in the database.
if (requestScope.n != null
&& requestScope.n < database.getDocumentCount()
&& requestScope.n >= 0) {
	var dc = database.getAllDocuments();
	var doc = dc.getDocumentArray()[requestScope.n];
	var schema = doc.getFirstChild(); // get node below root
	requestScope.y = "Child nodes of " + schema.getNodeName();
	var list = schema.getChildNodes();
	if(list.getLength() > 0) {
		for(var i=0; i<list.getLength></list.getLength> {
			requestScope.y = requestScope.y +
				"\n\t" + list.item(i).getNodeName();
		}
	} else {
		requestScope.y = requestScope.y + "\n\tNo elements";
	}
} else {
	requestScope.y = "No such document";
}
If the input XML to the DOM is as follows:
<schema0>
  <element0>foo</element0>
  <element1>bar</element1>
</schema0>
The display appears as follows:
Child nodes of schema0
	element0
	element1