Hi
I've checked out this page (and it works fine) in FF, IE, Opera, Chrome and Safari:
http://www.w3schools.c om/dom/tryit.asp?filen ame=try_dom_lis t_loop
But when I try and tweak it for a site I'm working on, it doesn't work in Chrome and Safari.
I used their exact external javascript to load the xml file:
And I use the same basic set up in javascript to display my results in the html page:
Here's a shorter version of the xml file I'm using:
So...it works in my 5 browsers when I use theirs on w3schools.com, but when I upload it all to our server, it won't work in Chrome and Safari.
I don't understand, any help would great. Thanks in advance!
I've checked out this page (and it works fine) in FF, IE, Opera, Chrome and Safari:
http://www.w3schools.c om/dom/tryit.asp?filen ame=try_dom_lis t_loop
But when I try and tweak it for a site I'm working on, it doesn't work in Chrome and Safari.
I used their exact external javascript to load the xml file:
Code:
function loadXMLDoc(dname)
{
var xmlDoc;
if (window.XMLHttpRequest)
{
xmlDoc=new window.XMLHttpRequest();
xmlDoc.open("GET",dname,false);
xmlDoc.send("");
return xmlDoc.responseXML;
}
// IE 5 and IE 6
else if (ActiveXObject("Microsoft.XMLDOM"))
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load(dname);
return xmlDoc;
}
alert("Error loading document");
return null;
}
Code:
<script type="text/javascript">
xmlDoc=loadXMLDoc("xml/stations.xml");
x=xmlDoc.getElementsByTagName('city');
for (i=0;i<x.length;i++)
{
document.write(x[i].childNodes[0].nodeValue);
document.write("<br />");
}
</script>
Code:
<?xml version="1.0" encoding="utf-8"?> <stations> <station> <city>City 1</city> <freq>105.7 FM</freq> </station> <station> <city>City 2</city> <freq>90.3 FM</freq> </station> </stations>
I don't understand, any help would great. Thanks in advance!
Comment