编辑您的代码:
查看结果:
<html> <body> <script type="text/javascript"> function loadXMLDoc(dname) { if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest(); } else { xhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.open("GET",dname,false); xhttp.send(""); return xhttp.responseXML; } xml=loadXMLDoc("../example/xmle/books.xml"); path="../bookstore/book[1]/title"; // code for IE if (window.ActiveXObject) { var nodes=xml.selectNodes(path); for (i=0;i<nodes.length;i++) { document.write(nodes[i].childNodes[0].nodeValue); document.write("<br />"); } } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { var nodes=xml.evaluate(path, xml, null, XPathResult.ANY_TYPE,null); var result=nodes.iterateNext(); while(result) { document.write(result.childNodes[0].nodeValue); document.write("<br />"); result=nodes.iterateNext(); } } </script> </body> </html>
查看结果:
系统帮助
|
给我留言
|
收藏本站
Copyright © 2005-2008
www.cnn84.com
All Rights Reserved Ver:2.0
桂公网安备45122402000102号
CNN84网是公益性便民网站,是为了给大家的日常生活查询及提供最快捷的出行指南
夜深了!要注意身体呀! CNN84希望所有朋友都能做个好梦!