getPreviousSibling (DOMNode - JavaScript)

Gets the previous node at the current level.

Defined in



getPreviousSibling() : DOMNode

Return value Description
DOMNode The previous child node or null.


This button gets the schema element of a DOM, then gets the elements at the next level in reverse order.
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 element = schema.getLastChild();
	while(element != null) {
		requestScope.y = requestScope.y +
			"\n\t" + element.getNodeName();
		element = element.getPreviousSibling();
} else {
	requestScope.y = "No such document";
If the input XML to the DOM is as follows:
The display appears as follows:
Child nodes of schema0