gpt4 book ai didi

javascript - XML 在 Firefox 和 IE 上评估 WrongDocumentError

转载 作者:行者123 更新时间:2023-11-27 22:32:22 33 4
gpt4 key购买 nike

我做了一个简单的 XML 请求,在 Chrome、Safari 等中一切正常。但在 Firefox 和 IE 中出现以下错误:

WrongDocumentError: Node cannot be used in a document other than the one in which it was created

消息引用的行是这样的:

var x = document.evaluate(path, xml.responseXML.documentElement, null, 9, null).singleNodeValue;

完整的函数如下:

function parseXMLID(xml, id) {

/* define product Array */
var productInfo = [];
var serialNumber = id;

/* set path for parse xml */
var path = '//productid[text()="' + serialNumber + '"]/..';

/* parse xml for path */
var x = document.evaluate(path, xml.responseXML.documentElement, null, 9, null).singleNodeValue;
}

你能看出我做错了什么吗?

希望你能帮助我,谢谢

最佳答案

您必须对您正在搜索的文档调用evaluate方法:

xml.responseXML.evaluate(path, xml.responseXML.documentElement, null, 9, null)

关于javascript - XML 在 Firefox 和 IE 上评估 WrongDocumentError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39445711/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com