Best XML parser for Java(Java 的最佳 XML 解析器)
问题描述
我需要读取较小的(最多几 MB,UTF-8 编码的)XML 文件,四处寻找各种元素和属性,也许修改一些并将 XML 再次写入磁盘(最好使用 nice,缩进格式).
I need to read smallish (few MB at the most, UTF-8 encoded) XML files, rummage around looking at various elements and attributes, perhaps modify a few and write the XML back out again to disk (preferably with nice, indented formatting).
什么是最适合我需要的 XML 解析器?有很多可供选择.我知道的一些是:
What would be the best XML parser for my needs? There are lots to choose from. Some I'm aware of are:
- JDOM
- 伍德斯托克斯
- XOM
- dom4j
- VTD-XML
- Xerces-J
- 深红色
当然还有 JDK 中的那个(我使用的是 Java 6).我对 Xerces 很熟悉,但觉得它很笨重.
And of course the one in the JDK (I'm using Java 6). I'm familiar with Xerces but find it clunky.
建议?
推荐答案
如果速度和内存都没有问题,dom4j 是一个非常好的选择.如果您需要速度,使用像 Woodstox 这样的 StAX 解析器是正确的方法,但是您必须编写更多代码才能完成工作,并且您必须习惯于在流中处理 XML.
If speed and memory is no problem, dom4j is a really good option. If you need speed, using a StAX parser like Woodstox is the right way, but you have to write more code to get things done and you have to get used to process XML in streams.
这篇关于Java 的最佳 XML 解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Java 的最佳 XML 解析器


- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- 转换 ldap 日期 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- 获取数字的最后一位 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01