var xmlDoc; var rand = parseInt(Math.random()*99999999); var url = ("this-week.xml?rand="+rand); function loadXMLDoc() { // XML loader for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLHTTP"); if (xmlDoc) { xmlDoc.onreadystatechange = printText; xmlDoc.open("GET", url, true); xmlDoc.send(); } } // XML loader for other browsers else { xmlDoc = new XMLHttpRequest(); xmlDoc.onreadystatechange = printText; xmlDoc.open("GET",url, true); xmlDoc.send(null); } } function printText() { //create XMLDOM object if xmlDoc shows "loaded" if (xmlDoc.readyState == 4) { // if "OK" if (xmlDoc.status == 200) { var image = xmlDoc.responseXML.getElementsByTagName("image")[0].childNodes[0].nodeValue; var links = xmlDoc.responseXML.getElementsByTagName("link"); var video = xmlDoc.responseXML.getElementsByTagName("video")[0].childNodes[0].nodeValue; var theimage = ''; var thetext = '' + xmlDoc.responseXML.getElementsByTagName("date")[0].childNodes[0].nodeValue + "

"; var titleNodes = xmlDoc.responseXML.getElementsByTagName("title"); for (var i = 0; i < titleNodes.length; i++) { thetext += ('> ' + titleNodes[i].firstChild.nodeValue + '

'); } if (video != "no") { thetext += ('
Watch Video
'); } document.getElementById('mainimage').innerHTML = theimage; document.getElementById('stories').innerHTML = thetext; document.close(); } else { document.getElementById('stories').innerHTML = "There was a problem retrieving the XML data"; } } }