W3C home > Mailing lists > Public > public-webapi@w3.org > April 2006

XMLHttpRequest.responseXML and invalid XML documents

From: Hallvord R. M. Steen <hallvord@opera.com>
Date: Fri, 21 Apr 2006 19:03:21 +0200
To: public-webapi@w3.org
Message-ID: <op.s8dazvgsa3v5gv@id-c0418.oslo.opera.com>

I've been asked to re-post some things I sent to the WHATWG list regarding  
XMLHttpRequest..

Originally posted to
http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2005-June/004119.html

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 R. M. Steen
Core QA JavaScript tester, Opera Software
http://www.opera.com/
Opera - simply the best Internet experience
Received on Monday, 24 April 2006 02:34:09 GMT

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