本文介绍了在XML中评估XPath表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用附加SDK创建Firefox附件时,如何处理XML文件?
使用XPath评估会抛出一个错误:

lockquote
XPathResult未定义

我正在处理:

var iterator = xmlDoc.evaluate('/ / stream',xmlDoc,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);


解决方案

是的,窗口中有很多全局类上下文不在沙箱的SDK模块中。您可以通过:
$ b

var {Ci} = require(chrome);
var iterator = xmlDoc.evaluate('// stream',xmlDoc,null,
Ci.nsIDOMXPathResult.ORDERED_NODE_ITERATOR_TYPE,null);


When using the Add-on SDK to create a Firefox add-on, how do you process an XML file?Evaluate with XPath throws an error:

I am trying to process this XML data with this code:

var iterator = xmlDoc.evaluate('//stream', xmlDoc, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
解决方案

Yes, a lot of global classes available in the window context aren't there in SDK modules which are sandboxes. You can access this constant via nsIDOMXPathResult interface:

var {Ci} = require("chrome");
var iterator = xmlDoc.evaluate('//stream', xmlDoc, null,
    Ci.nsIDOMXPathResult.ORDERED_NODE_ITERATOR_TYPE, null);

这篇关于在XML中评估XPath表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 16:39