在特定数量的条目后停止 XML 解析

发布于 2024-10-08 08:49:27 字数 119 浏览 0 评论 0原文

我目前正在使用 Poco::XML 通过 SAX 解析大量非常大的 XML 文件。对于其中一些文件,我只需要前 n 个条目。我想知道是否有人可以告诉我如何告诉 Poco::XML 在超过条目阈值后停止解析。

I am currently using Poco::XML to parse through a number of very large XML files using SAX. For some of those files I only need the first n number of entries. I was wondering if anyone can show me how to tell Poco::XML to cease parsing once I go over my threshold of entries.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如梦 2024-10-15 08:49:27

你正在寻找的是一个拉解析器,如果我正在寻找正确的库(我是一个java开发人员)poco确实支持拉解析。看这里 http://pocoproject.org/blog/?p=322

如果不是那么您需要在解析所需数量的记录后抛出一个异常来停止解析操作(使用标准 SAX API 时可能是 SAXException)。

好的,抛出异常将根据此处的 api 文档停止解析

What you are looking for is a pull parser and If I am looking at the correct library (I am a java developer) poco does support pull parsing. Look here http://pocoproject.org/blog/?p=322

If this is not the right library for you then you need to throw an exception that stops the parsing operation (may be SAXException when using standard SAX API) after parsing the number of records you want.

Ok, throwing an exception would stop the parsing according to the api doc here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文