Unable to extract data from XML file using javascript in Internet Explorer

hossini

New Member
The following code works fine in firefox but as with many other things, I cant get it working in Internet explorer (any version).Can anybody help?\[code\]<body> <script type="text/javascript"> 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","messages.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; var x=xmlDoc.getElementsByTagName("entry"); for (i=0;i<x.length;i++) { document.write("<b>From:</b> "); document.write(x.getElementsByTagName("username")[0].childNodes[0].nodeValue); document.write("<br />"); document.write("<b>Date:</b> "); document.write(x.getElementsByTagName("date")[0].childNodes[0].nodeValue); document.write("<br />"); document.write("<b>Message:</b> "); document.write(x.getElementsByTagName("message")[0].childNodes[0].nodeValue); document.write("<br />"); document.write("<br />"); } </script></body>\[/code\]
 
Back
Top