编辑下面的代码:【加编码】
<html> <head> <script src="/demo/loadxmldoc.js"> </script> <script> //check if the first node is an element node function get_firstChild(n) { y=n.firstChild; while (y.nodeType!=1) { y=y.nextSibling; } return y; } </script> </head> <body> <script> xmlDoc=loadXMLDoc("books.xml"); x=get_firstChild(xmlDoc.getElementsByTagName("book")[0]); document.write(x.nodeName); </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂