DOMParsing html

2 views
Skip to first unread message

g6...@cdf.toronto.edu

unread,
Feb 22, 2008, 10:52:25 PM2/22/08
to drprj-consu...@stanley.cdf.toronto.edu
Hi I hope this is the right forum for this, but I have a technical
question about the thunderbird code.

Right now when it takes an RSS feed, it uses an XMLHTTPRequest to
download the resource and overrides the mimetype as "text/xml"

(this referring to the Feed js object tbird uses)
this.request = Components.classes["@mozilla.org/xmlextras/
xmlhttprequest;1"]
.createInstance(Components.interfaces.nsIXMLHttpRequest);
this.request.overrideMimeType("text/xml");
this.request.onload = this.onDownloaded;

When the onload function onDownloaded is called,
this.request.responseText contains the resources content as a string
EG the RSS xml content
this.request.responseXML contains a DOM node for that xml content

However when given a url to a web page which is xhtml (EG:
http://www.engadget.com), responseXML just contains a node for a
"parsererror".

I tried using a DOMParser object to re-parse the responseText with
"text/html" or other but it seems to not work..

Does anyone know why this is?
Or where I should be asking this if not here?

Martin Honnen

unread,
Feb 29, 2008, 1:06:22 PM2/29/08
to
g6...@cdf.toronto.edu wrote:

> However when given a url to a web page which is xhtml (EG:
> http://www.engadget.com), responseXML just contains a node for a
> "parsererror".

Well try any XML parser e.g. the W3C validator
<URL:http://validator.w3.org/check?uri=http%3A%2F%2Fwww.engadget.com%2F&charset=%28detect+automatically%29&doctype=Inline&group=0>
and you will find that the document is not well-formed.
That is why you get a parse error.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Reply all
Reply to author
Forward
0 new messages