XML DOM - for loop not working in IE9

Spottbene

New Member
This works in Chrome, but does nothing in IE9. It loads data from a XML file on the server. Here is the code inside the index.html file:\[code\] <div id="content"> <script type="text/javascript"> xmlDoc=loadXMLDoc("content.xml"); var x=xmlDoc.getElementsByTagName("slot"); for ( i=0; i<x.length; i++ ) { document.write("<div id='tables'>"); document.write(x.getElementsByTagName("name")[0].childNodes[0].nodeValue + "<br />"); document.write(x.getElementsByTagName("type")[0].childNodes[0].nodeValue + "<br />"); document.write(x.getElementsByTagName("location")[0].childNodes[0].nodeValue + "<br />"); document.write(x.getElementsByTagName("site")[0].childNodes[0].nodeValue + "<br />"); document.write(x.getElementsByTagName("tot_power")[0].childNodes[0].nodeValue + "<br />"); document.write(x.getElementsByTagName("proj_power")[0].childNodes[0].nodeValue + "<br />"); document.write("</div>"); } </script> </div>\[/code\]Here is the loadXMLDoc.js:\[code\]function loadXMLDoc(dname){ 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",dname,false);xmlhttp.send();return xmlhttp.responseXML; }\[/code\]
 
Back
Top