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 解析器
基础教程推荐
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
