views:

167

answers:

1

I have the following code:

 if (window.XMLHttpRequest) {
    xmlHttp = new XMLHttpRequest();
}
else // for older IE 5/6
{
    xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
}

var url = 'payment/code/xmlrelay.php?t=rates&id=' + str;
xmlHttp.open('GET', url, false);
xmlHttp.send();
xmlDoc = xmlHttp.responseXML;
xmlResult = xmlDoc.getElementsByTagName('Result')[0].firstChild.nodeValue;

Accessing the following empty XML file from a webserver :

<?xml version="1.0" encoding="UTF-8"?><Property><Result>0</Result></Property>

or the following full one:

<?xml version="1.0" encoding="UTF-8"?>
<Property>
  <Result>1</Result>
  <Rateable>1</Rateable>
  <Location>123 Main Road, Everytown</Location>
  <Instalment>$100.00</Instalment>
</Property>

This works in Firefox, Chrome, Safari and Opera but in Internet Explorer 8 it returns the error "Object Required" for this line:

xmlResult = xmlDoc.getElementsByTagName('Result')[0].firstChild.nodeValue;

I've had a search around but have been able to find anything that works. Any suggestions would be appreciated.

Cheers Tama

+1  A: 

The problem was the content type of the XML file. It had a content type of

application/rss+xml

I changed that to

text/xml

and it all works fine now.

Thank you for your comments, sorry it was right under my nose all along.

Tama