Re: XMLHttpRequest.responseXML and invalid XML documents

Hallvord R. M. Steen wrote:
> 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.

Gecko doesn't ever return an empty document from XMLHttpRequest.  Sometimes it 
returns a bogus document with some "parseerror" markup in it due to 
<https://bugzilla.mozilla.org/show_bug.cgi?id=289714>; that's a bug that needs 
to be fixed.  But the document is never going to be completely empty; see 
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp&rev=1.147&mark=1431-1433#1425

> - FireFox *does* return null if the document is sent as text/html

Or anything else that doesn't look like an XML MIME type.  Or if a network error 
occurs.  Or if the user cancels the load.  An so forth.

-Boris

Received on Monday, 24 April 2006 02:42:09 UTC