Why does Opera parse my web page as XML?
Your document is not a valid HTML document. So, the browser should reject it. Unfortunately, due to a historic accident, most browsers do not reject invalid documents, but rather try to fix them (usually with pretty crappy results), so that the authro never even notices that his document is broken.
Thankfully, with XHTML, the browser vendors decided to fix that, and actually reject invalid documents. In your case, you are delivering your document as XHTML with the application/xhtml+xml
MIME type:
# curl --head http://www.logmytime.de/ HTTP/1.1 200 OK Cache-Control: private Content-Length: 12529 Content-Type: application/xhtml+xml; charset=utf-8 ^^^^^^^^^^^^^^^^^^^^^ Server: Microsoft-IIS/7.5 X-AspNetMvc-Version: 2.0 X-AspNet-Version: 2.0.50727 Set-Cookie: Referrer=None; path=/ X-Powered-By: ASP.NET Date: Tue, 04 May 2010 16:08:40 GMTSo, the browser rejects your document (as it should). When you switch over to HTML, then it tries to fix your broken HTML.
Now, you have changed your DOCTYPE
to HTML 4.01, but you are still delivering it as XHTML. All you have achieved now is that there are two reasons for the browser to reject your document: it's still invalid because you haven't fixed the actual bug and the DOCTYPE
and the MIME type don't match up.
Instead of mucking around with DOCTYPE
s and MIME types in order to get the browser to parse your broken document, the correct way to solve this problem would be to simply fix the invalid markup and remove the extraneous class
attribute on line 172. [BTW: who wrote that document? The indentation and formatting is awful.]
You have the "class" attribute specified two times.
From Well-formedness constraint: Unique Att Spec:
An attribute name MUST NOT appear more than once in the same start-tag or empty-element tag.
In case someone else has the same problem: As suggested by DeveloperArt it can be fixed with a simple ContentType="text/html" attribute in the page element.
Edit: The problem was in fact caused by a bug with the mobile.Browser file I am using in my web project. The workaround above works, but it is not really necessary in my case. See this answer for more details.