目前我正在尝试运行xPath,然后将每个结果集转换为DOM对象,以便我可以搜索一些内容,但是我一直收到DOM异常11或未捕获的TypeError:非法调用
代码:
getDataForOutput = function() {
log("Getting Loading Necessary Data from XML ["+settings.rowPath+"]");
if (window.ActiveXObject) {
var nodes=rawXML.selectNodes(path);
alert('Currently not IE compatible');
for (i=0;i<nodes.length;i++) {
//
}
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument) {
var nodes=rawXML.evaluate(settings.rowPath, rawXML, null, XPathResult.ANY_TYPE, null);
var result=nodes.iterateNext();
log(nodes);
while (result) {
//log("result");
for(i in settings.columns) {
if(typeof outputCols[i] == "function") { continue; }
if(typeof outputCols[i] == "undefined") { outputCols[i] = new Array(); }
//log($(result).find(settings.columns[i].tag)[0]);
var data;
//THE LINE BELOW CAUSES THE DOM EXCEPTION 11 TO HAPPEN....
var ele = $(result).find(settings.columns[i].tag)[0];
//THE LINE ABOVE IS EVIL. I EVEN TRIED TO USE:
//var ele = $(jQuery.extend({}, result)).find(settings.columns[i].tag)[0];
//BUT IT GIVES OFF: Uncaught TypeError: Illegal invocation
if(settings.columns[i].nodeName == true) {
data = result.tagName;
} else if(settings.columns[i].nodeValue == true) {
data = result.textContent;
} else if(typeof settings.columns[i].attr != "undefined") {
data = result.getAttribute(settings.columns[i].attr);
}
outputCols[i].push(data);
}
result = nodes.iterateNext(); //Gives Dom Excepti
}
}
log("Data loaded");
},
未捕获错误:InvalidStateError:DOM异常11
Uncaught Error: InvalidStateError: DOM Exception 11 xmlEditor.js:229
XMLEditor.getDataForOutput xmlEditor.js:229
XMLEditor.outputData xmlEditor.js:70
XMLEditor.loadXML xmlEditor.js:63
XMLEditor.init xmlEditor.js:23
XMLEditor xmlEditor.js:364
(anonymous function) edit_translation.html?page=cerep_assay_translation&sso.token=ffc469425b70b2…en&last_name=Brice&email=steven.m.brice@abbvie.com&external_id=bricesm1:22
l jquery-2.0.1.min.js:4
c.fireWith jquery-2.0.1.min.js:4
x.extend.ready jquery-2.0.1.min.js:4
S
未捕获的TypeError:非法调用
Uncaught TypeError: Illegal invocation jquery-2.0.1.min.js:4
t.nodeType.t.documentElement.i.find.TAG.n.getElementsByTagName.r jquery-2.0.1.min.js:4
St jquery-2.0.1.min.js:4
ot jquery-2.0.1.min.js:4
x.fn.extend.find jquery-2.0.1.min.js:5
XMLEditor.getDataForOutput xmlEditor.js:219
XMLEditor.outputData xmlEditor.js:70
XMLEditor.loadXML xmlEditor.js:63
XMLEditor.init xmlEditor.js:23
XMLEditor xmlEditor.js:366
(anonymous function) edit_translation.html?page=cerep_assay_translation&sso.token=ffc469425b70b2…en:22
l jquery-2.0.1.min.js:4
c.fireWith jquery-2.0.1.min.js:4
x.extend.ready jquery-2.0.1.min.js:4
S
答案 0 :(得分:0)
结束了这样做:
var ele = result.getElementsByTagName(settings.columns[i].tag)[0];