Hi again.
I have been trying to read an xml file using a combination of xmlhttprequest and activeObject to make it work for all browsers. This is my code. I cannot load the xml document at all, it returns no properties. Any idea?
var product = window.opener.message;
document.title = product;
var xmlStr = “’”+“xml/” + product + “.xml”+"’";
alert (xmlStr);
var browser=navigator.appName;
function getHTTPObject()
{
var xmlhttp;
if (browser==“Microsoft Internet Explorer”)
try
{
xmlhttp = new ActiveXObject(“Msxml2.XMLHTTP”);
}
catch (e)
{
try
{
xmlhttp = new ActiveXObject(“Microsoft.XMLHTTP”);
}
catch (E)
{
xmlhttp = false;
}
}
else
xmlhttp = false;
if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
try
{
xmlhttp = new XMLHttpRequest();
}
catch (e)
{
xmlhttp = false;
}
}
return xmlhttp;
}
var xmlHttp = getHTTPObject();
function processxmlHttpChange() {
// only if req shows “loaded”
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
// ...processing statements go here...
} else {
alert("There was a problem retrieving the XML data:
" +
xmlHttp.statusText);
}
}
}
function getDynamicData()
{
var url = xmlStr;
alert(“Hello” + xmlStr);
xmlHttp.open(‘GET’, url, true);
xmlHttp.onreadystatechange = processxmlHttpChange;
xmlHttp.send(null);
var dom = xmlHttp.responseXML;
alert(dom.documentElement.nodeName);
document.getElementById(“name”).innerHTML=dom.getElementsByTagName(“NAME”)[0].childNodes[0].nodeValue;
document.getElementById(“myPic”).src=dom.getElementsByTagName(“IMAGE”)[0].childNodes[0].nodeValue;
document.getElementById(“pack”).innerHTML=dom.getElementsByTagName(“PACK”)[0].childNodes[0].nodeValue;
document.getElementById(“des”).innerHTML=dom.getElementsByTagName(“DES”)[0].childNodes[0].nodeValue;
document.getElementById(“incr”).innerHTML=dom.getElementsByTagName(“INCR”)[0].childNodes[0].nodeValue;
document.getElementById(“use”).innerHTML=dom.getElementsByTagName(“USE”)[0].childNodes[0].nodeValue;
}
<body onload=“getDynamicData();”> etc etc