[whatwg] XMLHttpRequest.responseXML and invalid XML documents

Spec says about responseXML : 

> If the document was not an XML document, or if the document could
> not be parsed (due to an XML well-formedness error or unsupported
> character encoding, for instance), returns null.

All major browsers return an empty document instead under most of 
these conditions.

Exceptions:

- FireFox *does* return null if the document is sent as text/html
- FireFox and Opera guess UTF-8 encoding if the encoding sent from 
the server is unknown, and parses document.

Requiring that browsers return null may not be compatible with 
existing content. Scripts that today use for example
request.responseXML.getElementsByTagName()
would fail with an error if responseXML was null, and today there is 
virtually no point of saying "if(x.responseXML)" first since it will 
nearly always be a document object so no scripts will be written that 
way. Could we standardise returning an empty document instead, for 
all these conditions?
-- 
Hallvord Reiar Michaelsen Steen
http://www.hallvord.com/

Received on Wednesday, 22 June 2005 07:57:07 UTC