1

从一个类似的问题中,我发现了XPath,它看起来非常快,但我不能将它与 Node.js 一起使用:

> var xp = new XPathEvaluator();
ReferenceError: XPathEvaluator is not defined
    at repl:1:14
    at REPLServer.self.eval (repl.js:110:21)
    at repl.js:249:20
    at REPLServer.self.eval (repl.js:122:7)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.EventEmitter.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)
    at ReadStream.onkeypress (readline.js:99:10)

我可以以某种方式将其安装为模块吗?还是有替代方案?问题是我正在下载几个 RSS 提要,总共大约 900 个条目。我下载它们的时间不到一秒钟,但使用 jQuery 遍历每个元素

$(xml).find('entry').each(function() {  });

... 需要 10-15 秒,这对于 Web 服务是不可接受的。有什么建议么?

4

1 回答 1

1

如果您需要 node.js 的任何内容,请先访问http://npmjs.org,看看它是否不存在。对于像 XPath 遍历这样的常见事情,它通常会这样做。在这种情况下:https ://npmjs.org/package/xpath

于 2013-06-21T16:43:59.660 回答