This question is not specific to Linux but maybe some of the gurus around here will know how to solve my problem.
I'm loading an XML file stored in a tiny web server (based on lwip). This web server is not very cooperative and is not marking the http content-type as "text/xml". As result, Firefox is not recognizing the file as xml (IE does) so I can't use DOM methods for parsing the xml file.
overrideMimeType("text/xml") should help me avoid this problem but, even having overrided the mymetype, the content-type received is still "text/plain".
This is a portion of my JavaScript code:
Code:
var xmlObj;
// loadXMLdata is called from the html file
function loadXMLdata()
{
var dataFile = window.location.href.substring(0, window.location.href.lastIndexOf("/") + 1) + "config/myfile.xml";
if (window.XMLHttpRequest)
{
xmlObj = new XMLHttpRequest();
// This should override the mimetype...
if (xmlObj.overrideMimeType)
xmlObj.overrideMimeType("text/xml");
xmlObj.onreadystatechange = fillXMLdata;
xmlObj.open("GET", dataFile, true);
xmlObj.send("");
}
else
{
alert("Your browser can not handle this script");
return;
}
}
// fillXMLdata is called from loadXMLdata once the xml object is ready
function fillXMLdata()
{
if (xmlObj.readyState == 4)
{
// Here Content-Type shows again "text/plain"
alert(xmlObj.getAllResponseHeaders());
var xmlDoc = xmlObj.responseXML.documentElement;
// And here section is null
var section = xmlDoc.getElementsByTagName("section")[0];
}
}
The xml is quite simple:
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<section>
<item>1</item>
<item>2</item>
</section>
Thanks guys for your comments.
Daniel.