实例首页
自学教程
IT工具箱
源代码
下载代码
上下布局
点击运行 >
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>自学教程(runoops.com)</title> <script src="//demo.runoops.com/sources/xml/loadxmldoc.js"></script> <script> // 检测第一个节点是否为元素节点 function get_firstChild(n) { y = n.firstChild; while (y.nodeType != 1) { y = y.nextSibling; } return y; } </script> </head> <body> <script> xmlDoc = loadXMLDoc("//demo.runoops.com/sources/xml/books.xml"); x = get_firstChild(xmlDoc.getElementsByTagName("book")[0]); document.write(x.nodeName); </script> </body> </html>
运行结果: