[whatwg] XMLHttpRequest.responseXML and invalid XML documents

Hallvord Reiar Michaelsen Steen hallvord at hallvord.com
Wed Jun 22 07:57:07 PDT 2005

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.


- 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
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

More information about the whatwg mailing list