External node troubles [FF3 RC1]
noon <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <37e47414-0d34-4f18-b8a4-a75cb84989c2@j22g2000hsf.googlegroups.com> |
Note: This is for FF3 RC1
I'm running an XMLHttpRequest against a site, any site, and then
parsing the contents with DOMParser and XMLSerializer. I have the
following code
// html is the responseText from my XHR
$('test').adoptNode = html.split(/<body[^>]*>((?:.|\n)*)<\/body>/i)
[1]; // xmlserializer needs a dom object
var p = new DOMParser(), xs = new XMLSerializer();
var doc = p.parseFromString(xs.serializeToString($('test')),"text/
xml");
var div = document.createElement('div');
var alt = $x("//IMG/@alt", doc); // result: Node cannot be used in a
document other than the one in which it was created
var alt1 = $x("//IMG/@alt", document.adoptNode(doc)); // result:
Operation is not supported (NS_ERROR_DOM_NOT_SUPPORTED_ERR)
function $(item) {return document.getElementById(item);}
function $x(p, context) {
if (!context) context = document;
var i, arr = [], xpr = document.evaluate(p, context, null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (i = 0; item = xpr.snapshotItem(i); i++) arr.push(item);
return arr;
}
Help on these two errors?