Tryit Editor v1.8

Source Code:
<!DOCTYPE html> <html> <head> <script src="loadxmldoc.js"> </script> </head> <body> <script> //check if the last node is an element node function get_lastchild(n) { x=n.lastChild; while (x.nodeType!=1) { x=x.previousSibling; } return x; } xmlDoc=loadXMLDoc("books.xml"); x=get_lastchild(xmlDoc); document.write("Nodename: " + x.nodeName); document.write(" (nodetype: " + x.nodeType + ")<br>"); //Get the last child node of the root element y=get_lastchild(xmlDoc.documentElement); document.write("Nodename: " + y.nodeName); document.write(" (nodetype: " + y.nodeType); </script> </body> </html>
Result:
W3Schools.com - Try it yourself