Code:<html> <body> <script> if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new activeXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","cd_catalog.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; document.write("<table border='1'>"); var x=xmldoc.getelementsbytagname("cd"); for (i=0;i<x.length;i++) { document.write("<tr><td>"); document.write(x[i].getelementsbytagname("artist")[0].childnodes[0].nodevalue); document.write("</td><td>"); document.write(x[i].getelementsbytagname("title")[0].childnodes[0].nodevalue); document.write("</td></tr>"); } document.write("</table>"); </script> </body>
Bookmarks