If have a strange problem with the handling of XML files in the Chrome browser
My hardware setup is a Mega2560 with an W5100 ethernet shield (incuding mini SD Card).
I'm using the Arduino 1.0.1 IDE and its Ethernet library.
I've programmed the Mega to run as a web server with the web server files stored on the SD Card. There are HTML, IMAGES, JS and XML files stored on the SD card. The Arduino also generates certain xml itself and sends these via the ethernet w.5100 server functions.
My Arduino web server, pages and xml files work perfectly when using the IE 9, FIREFOX 16.0.1 AND Sarafi 5.1.7 browsers.
But for some reason my XML files don't work correctly in Chrome 22.0.
The strange problem is
If the xml files are read from the SD Card they work in Chrome. But the XML files generated directly by the Arduino code itself do work at all in Chrome.
There must be some difference in the content of the xml files depending on whether the file comes from the SD Card or from the Arduino.
I have looked at the xml data using an HTTP debugger and I can see that the xml files are being requested by Chrome and sent to Chrome.
There is no obvious difference between the xml data from the SD Card or from the Arduino.
below is a snippet of code I am using to generate one xml file on the Arduino.
client.println("HTTP/1.1 200 OK");
client.println("Content-Length: 110");
client.println("Content-Type: application/xml");
client.println("Server: Arduino");
client.println();
client.println("<?xml version=\"1.0\"?>");
client.println("");
client.print("");
char datestr[24];
DateTime t = RTC.now();
char daysInWord[3];
DayInStr(daysInWord,day_of_week(t.day(), t.month(), t.year()));
client.print(daysInWord);
client.print(" ");
sprintf(datestr,"%02d-%02d-%04d %02d:%02d:%02d",t.day(),t.month(),t.year(),t.hour(),t.minute(),t.second());
client.print(datestr);
client.println("");
client.print("");
if (NTP_Status) {
client.print("Ok");
}
else {
client.print("Failed");
}
client.println("");
client.println("");
client.println();
And this is an extract of the code I'm using to read and send XML files from the SD Card.
while ((c = dataFile.read()) >= 0) {
buf[bufindex++]=((char)c); //fill buffer
if(bufindex >= maxbyte) //empty buffer when maximum length is reached.
{
client.write(buf, maxbyte);
bytecount = bytecount+maxbyte;
bufindex=0;
}
}
Can anyone help me understand what could be different between an xml file from the SD Card and an XML file generated by the Arduino?
Remember everything works in IE, Firefox and Safari. This problem only happens in Chrome????? But Why???