如何监控 Java 中的 XML 解析(使用 JDOM)?
我正在开发一个可以解析大型 XML 文件(超过 200k 行,大约 4-5 MB)的应用程序,并且我想使用进度条来监视解析。 我正在使用 JDOM v1.1.1 和 SaxBuilder。
有人知道如何实现这一目标吗?
谢谢
I'm developing an app that parses big XML files (over 200k lines, about 4-5 MB), and I would like to monitor the parsing using a progress bar.
I'm using JDOM v1.1.1 and SaxBuilder.
Anyone knows how to achieve that ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想,您可以对 org.jdom.DefaultJDOMFactory 进行子类化,并重写一些方法来跟踪某些节点的创建时间。然后,您可以将该子类的对象传递给
SAXBuilder.setFactory
。不过,由您来决定什么构成“进度”,您只能根据 XML 的结构来决定。
You could, I suppose, subclass
org.jdom.DefaultJDOMFactory
, and override some of the methods to track when certain nodes get created. You can then pass an object of that subclass to theSAXBuilder.setFactory
.It's be up to you to decide what constitutes "progress", though, which you'll only be able to decide based on the structure of the XML.