[Greasemonkey] Re: responseXML for GM_xmlhttpRequest

Nikolas Coukouma lists at atrus.org
Fri Jul 8 03:26:15 EDT 2005

Lenny Domnitser wrote:

>> I seem to remember someone (*poke, Mark*) declaring text/xml
>>officially evil. But maybe we should actually use the response type?
>>Cuz you know, hard-coding a mime type feels dirty to me.
>That is what I thought should be done. I used text/xml because I read
>in a comment in some Mozilla code that it is to be parsed as text/xml
>[1], but on inspection of code in a separate source file, it is only
>parsed as text/xml if no content type is sent [2].
>I'm not sure if GM should follow Mozilla's code exactly or instead use
>application/xml if no content type is provided. Using text/xml instead
>of application/xml might be a bug in Mozilla (somebody check RFC 3023,
>as I will not wade through that whole thing now). GM should probably
>mirror Mozilla's default content type, and if it ever changes, follow
>[1]: http://lxr.mozilla.org/aviary101branch/source/extensions/xmlextras/base/public/nsIXMLHttpRequest.idl#98
>[2]: http://lxr.mozilla.org/aviary101branch/source/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp#1071
>[RFC 3023]: http://www.ietf.org/rfc/rfc3023.txt
All that matters is that it's one of the content types that DOMParser
handles. If you try to parse a type that it doesn't handle, it will
throw a NOT_IMPLEMENTED error. It's entirely internal, so I see no
reason to worry about standard default content types. The only reason to
change it would be if the parser stopped accepting text/xml, and I don't
think that's happening. They assume an XML type because it's XMLHttpRequest.

I'll note that DOMParser DOES NOT handle HTML. Period. Adding HTML
parsing is non-trivial at the moment because of details in the way HTML
parsing is done. Boris Zbarsky sums up the situation nicely in a google
groups post[1].


-Nikolas Coukouma

More information about the Greasemonkey mailing list