[Project_owners] Load HTML into DOM?

Bradley Rintoul brintoul at sbcglobal.net
Thu Feb 10 06:28:08 EST 2005

Rod Whiteley wrote:

> Bradley Rintoul wrote:
>> ...it's HTML. What I'd like to do is load this into a DOM...
> I suppose you can use nsIDOMParser for that.  It seems to parse HTML 
> in a string or a stream and return a document.  I have not tried it 
> myself.
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners

I tried using the DOMParser but it didn't work. 

The documentation says: "The first argument to the parseFromString 
method is the string to parse. The second argument is the content type 
of the string. Currently only XML is supported so you should use 
'text/xml', 'application/xml' or 'application/xhtml+xml' as the content 
type. The DOMParser does not parse HTML, although naturally it will 
parse XHTML. You could use the innerHTML property of an element to 
handle non-XML HTML."

So I'm trying to create a new document using 
document.implementation.createDocument and setting its innerHTML to the 
responseText, but so far no luck.  Do I need to create a "root element" 
in the newly created DOMDocument..?

Thanks for the response.

More information about the Project_owners mailing list