Reputation: 317
I'm using this bit of code in javascript and it works great as long as the files I'm opening have a .xml extension.
function loadXMLDoc(filename)
{
if (window.ActiveXObject){
xhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
else {
xhttp = new XMLHttpRequest();
}
xhttp.open("GET", filename, false);
try {xhttp.responseType = "msxml-document"} catch(err) {} // Helping IE11
xhttp.send("");
return xhttp.responseXML;
}
I have no control over the filenames. How can I change this code to open XML files that don't have a .xml extension?
Side note: I only need it to work in IE.
Upvotes: 0
Views: 105
Reputation: 163312
It's not the file extension that matters, it's the HTTP media type. Your web server is probably configured to serve .xml files with the application/xml media type; you can also configure it to serve files with other extensions with this media type.
(Though somewhere lurking in my distant memory is the recollection that Internet Explorer has quirks in this area, ie. it does more with file extensions than it should.)
Upvotes: 1