简体   繁体   English

JavaScript:使用xmlDoc.evaluate()时出现命名空间错误

[英]JavaScript: Namespace error when using xmlDoc.evaluate()

I'm trying to get an XPathResult object using the evalute() function on a xml document object: 我正在尝试使用xml文档对象上的evalute()函数来获取XPathResult对象:

var nodes= xmlDoc.evaluate(XMLPath,xmlDoc,null,XPathResult.ANY_TYPE,null);

even though the namespaceResolver parameter is null and I am using a very simple XML file without any name spaces declared, Firefox throws the following error on the line: 即使namespaceResolver参数为null并且我使用的是一个非常简单的XML文件,但未声明任何名称空间,但Firefox仍在行上抛出以下错误:

NamespaceError: An attempt was made to create or change an object in a way which is incorrect with regard to namespaces NamespaceError:尝试以一种与名称空间有关的方式来创建或更改对象

Where is my error? 我的错误在哪里? Thanks in advance! 提前致谢!

Ok, my bad. 好吧,我的坏。 The error was hiding in the actual XPath I used. 错误隐藏在我使用的实际XPath中。 Problem solved. 问题解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM