W3C home > Mailing lists > Public > public-webapi@w3.org > June 2007

XMLHttpRequest.responseXML returning null for non-XML MIME types

From: Geoffrey Garen <ggaren@apple.com>
Date: Fri, 29 Jun 2007 13:34:46 -0700
Message-Id: <0E986F53-3533-44C5-A7DF-0A4A67D02C87@apple.com>
To: public-webapi@w3.org

Hi folks.

The XMLHttpRequest spec says that, if an HTTP response contains a  
content-type header that is not XML, XMLHttpRequest .responseXML  
should return NULL (http://www.w3.org/TR/XMLHttpRequest/#xml-response-entity-body 
).

I'm looking into this issue because it has broken a widget on Mac OS  
X. The widget uses XMLHttpRequest to load a valid XML file and then  
read responseXML. Unfortunately, the file comes to use with an  
incorrect MIME type (application/octet-stream), so we return NULL and  
later throw an exception.

To me, it seems preferable to try to parse the response as XML,  
returning NULL only if parsing fails. The spec already says you should  
do this if the content-type header is missing. Why not do it always?

Thanks,
Geoff
Received on Friday, 29 June 2007 20:34:57 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:18:57 GMT