function traverse(elem) {var i; if (elem.children != null)//if there are child elements { for (i=0; i < elem.children.length; i++) //repeat over all children output_doc(elem.children.item(i)); //do the tests and the output for every child } }