Android:最好的 XML 解析库?
我必须在 Android 应用程序中解析一些复杂的 xml 文件。有没有什么好的库可以做到这一点,比如 iPhone 的 TouchXMl?
I have to parse some complex xml files inside my Android application. Is there any good library for doing that like there is TouchXMl for iPhone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
或者您可以使用 org.xmlpull.v1.XmlPullParser - 我发现它比 SAX 解析器更容易使用,并且它还有其他好处:
http://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html
http://www.bearcave.com/software/java/xml/xmlpull.html
Or you could use the org.xmlpull.v1.XmlPullParser - I've found it much easier to use than the SAX Parser and it has other benefits:
http://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html
http://www.bearcave.com/software/java/xml/xmlpull.html
SAX XML 解析器 已内置于 Android SDK 中。
The SAX XML Parser comes already built into the Android SDK.
使用Woodstox。它是一个 Stax pull 解析器,实际上支持所有 XML(与捆绑的 xmlpull 不同),高效、成熟。为了更方便,StaxMate 也有帮助,使用 Woodstox(或任何其他 Stax 解析器)进行解析,但公开方便的游标和编写器;但仍然比 DOM 方法快 3 倍到 5 倍。
提到的 XmlPullParser 在某种程度上可以工作,但无法处理 DTD(不仅是验证,甚至是基本字符实体),给出神秘的错误消息,并且没有标准接口(SAX 或 Stax)。
Use Woodstox. It's a Stax pull parser, actually supports all of XML (unlike xmlpull that is bundled), efficient, mature. For more convenience, StaxMate helps too, uses Woodstox (or any other Stax parser) for parsing but exposes convenient cursors and writers; but is still 3x - 5x faster than DOM approach.
XmlPullParser that was mentioned works to some degree, but can't handle DTDs (not just validation but even basic character entities), gives cryptic error messages and doesn't have standard interface (SAX or Stax).
不知道定义“最佳”的标准。但这里有一篇最近的研究论文,详细分析了现有的 java xml 框架...
http://recipp.ipp.pt/bitstream/10400.22/1847/1/ART_BrunoOliveira_2013.pdf
Don't know the criteria by which "best" is defined. but here is a recent research paper that analyzes existing java xml framework with great details...
http://recipp.ipp.pt/bitstream/10400.22/1847/1/ART_BrunoOliveira_2013.pdf