Click to See Complete Forum and Search --> : Ajax: responseXML in Internet Explorer fails


wakeup
02-09-2006, 09:08 AM
I'm requesting a xml file in javascript from a xmlhttprequest object:
requester.responseXML

It runs ok in firefox, but in IE it returns null. (requester.resonseText run ok).

Searching in google I found this solution:
http://forum.java.sun.com/thread.jspa?threadID=696590&tstart=105

[code]/Just to check if it is a different navigator from internet explorer
if (document.implementation && document.implementation.createDocument){
xmlDoc = requester.responseXML;
//In case to be the internet explorer
} else if (window.ActiveXObject){
//Create a xml tag in run time
var testandoAppend = document.createElement('xml');
//Put the requester.responseText in the innerHTML of the xml tag
testandoAppend.setAttribute('innerHTML',requester.responseText);
//Set the xml tag's id to _formjAjaxRetornoXML
testandoAppend.setAttribute('id','_formjAjaxRetornoXML');
//Add the created tag to the page context
document.body.appendChild(testandoAppend);
//Just for check put the xmlhttp.responseXML in the innerHTML of the tag
document.getElementById('_formjAjaxRetornoXML').innerHTML = requester.responseText;
//Now we can get the xml tag and put it on a var
xmlDoc = document.getElementById('_formjAjaxRetornoXML');
//So we have a valid xml we can remove the xml tag document.body.removeChild(document.getElementById('_formjAjaxRetornoXML'));\n" +
}
else{
//If the browser doesnt support xml
alert('Your browser can\\'t handle this script');
}[code]

It runs ok but, I want know another solution more simple. How do you do it?
Thanks


_______________________
Hip Hop Directo (http://www.hhdirecto.net)

A1ien51
02-09-2006, 10:25 AM
Already responded here: http://www.codingforums.com/showthread.php?t=79228

Eric