适用于Java的小型,简约且快速的XML库? [英] Small, minimalistic and fast XML library for Java?

查看:143
本文介绍了适用于Java的小型,简约且快速的XML库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时我需要解析XML文件 - 并且只解析,我不想通过 String.indexOf 手动执行此操作。所以我需要使用可能最小和最快的XML解析库。不幸的是,我不知道类似于 GSON (180kb)的任何内容。

Sometimes I need to parse XML file - and only parse, and I don't want to do this manually via String.indexOf. So my need would be to use possibly smallest and fast XML parsing library. Unfortunatelly, I don't know anything similar to GSON (180kb).

我已导入 dom4j ,但之后我有异常:

I've imported dom4j, but after that I've got exception:

java.lang.NoClassDefFoundError:org / jaxen / JaxenException

java.lang.NoClassDefFoundError: org/jaxen/JaxenException

所以我添加了 jaxen 依赖(maven),这是一个非常令人震惊的经历:大约增加了7MB的依赖项,其中最大的是 xercesImpl icu4j

So I've added jaxen dependency (maven), and this is very shocking experience: about 7MB dependencies added, the biggest from them xercesImpl and icu4j.

另一个猜测是 Jericho ,但这主要用于解析格式错误的HTML,而且它超过2MB - 肯定会有更小的可用内容。

Another guess is Jericho, but this is mostly designed for parsing bad-formed HTML, and it's over 2MB - surely there could be something smaller available.

那么,你能推荐我一些好的图书馆吗?最小的代码大小是最重要的。最好它的大小应该是 GSON

So, could you please recommend me some good library? The minimal code size is the most important thing here. At best it should about the size of GSON.

推荐答案

看一下NanoXML - 下载网站

Have a look at NanoXML - download site

这是一个非常小的DOM-基于解析器库,我过去使用它并且运行良好。它不一定有效,但它很小。

It is a very small DOM-based parser library, I've used it in the past and it worked well. It is not necessarily efficient but it is tiny.

这篇关于适用于Java的小型,简约且快速的XML库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆