I have a small issue with reading XML documents. My code works fine in IE - where it shows an alert box with my XML file in it - but not in Firefox. What could be the problem ?
The XML Document :
Code:
function loadXML(file) {
var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
var ie = (typeof window.ActiveXObject != 'undefined');
var xmlDoc;
if (moz) {
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.async = false;
}
else if (ie) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
}
xmlDoc.load(file);
return xmlDoc;
}
readDocument();
function readDocument() {
var xmlDoc = loadXML("Calendar4.xml");
var years = xmlDoc.getElementsByTagName('year');
alert(xmlDoc.xml);
}
The XML Document :
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Calendar>
<Year id="2005">
<Month id="1" name="January">
<Week id="1">
<Day name="Thursday"/>
</Week>
</Month>
</Year>
</Calendar>