I am doing a project in which I have to send an XML with arduino to a webpage for representing different values from sensors. I know there are tutorials about this on the internet but I am really stucked because of everything looks good but the XML is not recognized by the browser but it is recognized as a text file without format.
This is how the XML file looks like:
<?xml version = '1.0' encoding='UTF-8'?>
<inputs>
<dato>
15
</dato>
</inputs>
If you are transferring the file through http, you must send a valid http header. In that header, make sure you have text/xml (or application/xml) as your Content-Type.
I have used the validator and the result is that when I put the file with headers it detects the document as an HTML 4.01 transitional and detects 2 errors. When I put the document whitout the headers it tells me that it is an XML document and everything is ok!! This is crazy!! What's happening??
Robin2:
Have you another (non-Arduino) way to send the valid XML to the server?
If so can you see exactly what that sends and compare it to what your Arduino code sends ?
I have so far avoided XML but I wonder if you are confusing the content of the XML message and the "envelope" in which it is sent to the server.
...R
I have programmed the XML in arduino following the tutorial of startingelectronics, that's why I am so confused of what I am doing wrong because the response is written the same way.
I will try to find a way to send an XML response as I am doing with arduino and I will write the result.
gcp900:
I have used the validator and the result is that when I put the file with headers it detects the document as an HTML 4.01 transitional and detects 2 errors. When I put the document whitout the headers it tells me that it is an XML document and everything is ok!! This is crazy!! What's happening??
What seems to be happening is that whatever you are using to send the file is already putting in the HTTP headers. This is what I'd normally expect, anyway - you'd be using a library to do that stuff. If you put that stuff at the start of an XML file, it is no longer valid XML, so the receiver is making its next best guess and treating it as (bad) HTML.
For everyone who wants to manage XML files (or HMTL files) with arduino yun, IT IS MANDATORY TO USE THIS HEADERS BEFORE PRINTING THE RESPONSE because if not it would be treated as a plain text.