Hello,
I need some help to solve the following problem. I wrote some html/javascript code to read data from an XML file:
XML file:
<places>
<place year="2000" name="Amsterdam" />
<place year="2000" name="Amstelveen" />
</places>
html/javascript code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>XML Test
</title>
<style type="text/css">
</style>
<script language="JavaScript" type="text/javascript">
var xmlDoc;
function load () {
//for IE7
if (window.ActiveXObject) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.onreadystatechange = IE_verify;
xmlDoc.load("places.xml");
var xmlObj = xmlDoc.documentElement;
Show (xmlDoc);
}
//for FF
else if (document.implementation && document.implementation.createDocument) {
xmlDoc = document.implementation.createDocument("","",null) ;
xmlDoc.async = false;
xmlDoc.onload = function (evt) {Show (xmlDoc);};
xmlDoc.load("places.xml");
}
}
function IE_verify(xmlDoc) {
// 0 Object is not initialized
// 1 Loading object is loading data
// 2 Loaded object has loaded data
// 3 Data from object can be worked with
// 4 Object completely initialized
if (xmlDoc.readyState != 4) {
return false;
} else {
return true;
}
}
function Show (xmlDoc) {
var places = xmlDoc.getElementsByTagName ("place");
var count = places.length;
var Place = new Array();
for (var i=0; i<count; i++) {
Place [i] = new Array (
places[i].getAttribute ("year"),
places[i].getAttribute ("name"));
document.writeln (Place[i][0]
+ ", " + Place[i][1]
+ "<br>");
}
}
</script>
</head>
<body onload="load()">
</body>
</html>
This runs for IE7 and FireFox nicely locally on my PC. However, if I upload it to my homepage, then only IE7 displays the data; there is no data displayed in FireFox, no errors on the FF error console.
Who knows what's wrong?