Re: External node troubles [FF3 RC1]
Boris Zbarsky <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Message-ID | <[email protected]> |
noon wrote:
> Its well formed enough to be parsed but the responseXML still chokes
> with not well-formed errors.
Odd. DOMParser and responseXML use the same exact parser.
>> The latter. So you can get the doc.documentElement from the DOMParser result
>> document, and adopt that element.
>
> The context that I am using this method in is quite dynamic so it
> isn't easy to say adopt one element.
I'm not sure what the issue is here... you get back a document from the
DOMParser, right? What's wrong with adopting its documentElement and then doing
whatever you want with it?
> I have made some progress because I can parse and then use functions like getElementsByTagName
> against this |doc| node. But my goal is to be able to use xpath.
So use it. But use it on |doc|, not on |document|. Or adopt the nodes into
|document| and use it on |document|. The key is calling evaluate() on the
ownerDocument of the context node, whatever document that is.
> |doc|.innerHTML fails because it is an XML type and |doc|.BODY doesn't exist.
doc.documentElement should exist, I would think.
> Since I can't adopt |doc| the next best thing would be to generically
> adopt EVERY child node of it
You adopt the documentElement, which adopts the entire subtree rooted at it.
Then you do whatever you want with it.
> $('test').innerHTML = html // xmlserializer needs a dom object
Ah, so this is where you real parsing happens: this parses your data as HTML.
> // Not sure what to adopt, I need a catch-all. doc.BODY is undefined
I think I've mentioned doc.documentElement multiple times now, including in my
first posts in this thread...
-Boris