源代码 :
点击运行
<!DOCTYPE html> <html> <head> <script src="loadxmldoc.js"> </script> <script> // 获取节点的最后一个子节点 function get_lastChild(n) { y=n.lastChild; while (y.nodeType!=1) { y=y.previousSibling; } return y; } </script> </head> <body> <script> xmlDoc=loadXMLDoc("books.xml"); x=get_lastChild(xmlDoc.getElementsByTagName("book")[0]); document.write(x.nodeName); </script> </body> </html>
运行结果