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