strange xml Javascript error

wxdqz

New Member
Hi all,

This script runs fine executed from my browser but when I upload the file and test it I get a "xml.documentElment is null or not an object" error. The script calls a getEvents function which should return data from a xml file based on the month=1 through 12 and the day=1 through 31.

Here is the pertaining javascripts:

First function:

<!-- The function to reset the date values in the buttons of the slots.-->
// function require currentdate, current day, and number of days in month
function fillDates(cDate, cDay, noOfDaysInmnth) {
//fillDates(currentDate, DayofWk, noOfDaysInmnth)
var startDay = (((cDate - (cDay +1))%7)-7);
var slotInd, slotName, val, events;
//slotIndx = (startDay * -1);
var j = (startDay)*(-1)+1;
var cmnth = getCMnth(); //calls function to return current month
var m = cmnth + 1;

for( var i = 1; i <=(noOfDaysInmnth+(j-1)); i++){
slotName = "d"+j;
val = i;
if( val < 1 || val > noOfDaysInmnth){break;}
else{val = i;}
events = "<br/><i><small>" + getEvents(m,val) + "</small></i>";//<--LINE THAT CALLS GETEVENTS FUNCTION
writeDivs(val, slotName, events);//Writes to Div tags via innerHtml
if(j > 0 && j < 42)
j++;
else
break;
}//End For Loop
}//fillDates()

Second Function:

<!--"Read from XML File "-->
function getEvents(mnth, day){ //function relies on the current month and day to read the xml file
var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
var days_event, eventNode;
//xmlDoc.async = "false";
xmldoc.load("events.xml");
//you have to subtract by one since the nodes value operates like an array starting from "0"
//this only has to be done for the month element however
if(xmldoc.documentElement.childNodes(mnth-1).childNodes(day) == null)
eventNode = '0';
if(xmldoc.documentElement.childNodes(mnth-1).childNodes(day) != null)
eventNode = xmldoc.documentElement.childNodes(mnth-1).childNodes(day).childNodes(1);

var events = eventNode.text;
return events;
}//getEvents


I didn't want to list the entire xml file because of it's lenghth but here is an extract:


<?xml version="1.0" encoding="utf-8"?>
<year>
<month desc = "Jan">1
<day>1<event></event></day>
<day>2<event></event></day>
<day>3<event></event></day>
<day>4<event></event></day>
<day>5<event></event></day>
<day>6<event></event></day>
<day>7<event></event></day>
...
<day>31<event></event></day>
...
...
<month desc = "Dec">12
<day>1<event></event></day>
...
</year>

Like I said it works fine on my desktop-no errors at all but once uploaded I get this error about documentElement is null. Any Thoughts?!?
 
Back
Top