Re: External node troubles [FF3 RC1]
Boris Zbarsky <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Message-ID | <[email protected]> |
noon wrote:
> // html is the responseText from my XHR
> $('test').adoptNode = html.split(/<body[^>]*>((?:.|\n)*)<\/body>/i)
> [1]; // xmlserializer needs a dom object
You're really assigning that to adoptNode? That's a little odd... And why not
use the responseXML instead of parsing it yourself? In any case...
> var alt = $x("//IMG/@alt", doc); // result: Node cannot be used in a
> document other than the one in which it was created
You're passing |doc| as the context to document.evaluate. The node passed to
document.evaluate as the context must either be |document| or a node whose
ownerDocument is |document|. That's pretty clearly documented in the DOM XPath
spec.
> var alt1 = $x("//IMG/@alt", document.adoptNode(doc)); // result:
> Operation is not supported (NS_ERROR_DOM_NOT_SUPPORTED_ERR)
You can't adopt Document nodes. You _can_ adopt doc.documentElement, though,
and that might be what you want here. Again, all that is clearly documented in
the DOM specs.
-Boris