问题标签 [tinyxpath]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
217 浏览

c++ - 使用 TinyXPath 搜索 XPath 时的性能问题

我有一个相当大的 XML 文件(~11MB),我正在使用 TinyXPath 来定位一些节点。尽管我试图定位的节点不能与稍后在 DOM 中的其他节点混淆,但 XPath 查询需要几分钟才能返回。

这是我的示例 XML:

这是我的 C++ 代码:

从暂停和检查堆栈跟踪来看,它似乎正在尝试解析和遍历整个 XML 结构。但是,RootElement只有 2 个子节点:HeaderEventReport。而且由于我没有在(非常大的)EventReport节点下寻找任何东西,我希望这个查询会非常快。

此外,如果我将示例 XML 缩小为仅包含几个SomeEvent节点,则此查询几乎会立即返回。

这是 TinyXPath 的已知限制吗?有没有更好的方法来构建我的查询以及时返回?