Android: DOM vs SAX vs XMLPullParser parsing?(Android:DOM vs SAX vs XMLPullParser 解析?)
问题描述
我正在使用 SAX Parser 解析 XML 文档.
I am parsing XML Document using SAX Parser.
我想知道使用 DOM、SAX Parser 或 XMLPullParser 哪个更好更快.
I want to know which is better and faster to work with DOM, SAX Parser or XMLPullParser.
推荐答案
这取决于你在做什么,如果你有非常大的文件,那么你应该使用 SAX 解析器,因为它会触发事件并释放它们,没有任何东西存储在内存,并且使用 SAX 解析器,您不能以随机方式访问元素,没有回头路!,但 Dom 允许您访问 xml 文件的任何部分,因为它将整个文件/文档保存在内存中.希望这个回答你的问题.
it depends on what are you doing , if you have very large files then you should use SAX parser since it will fire events and releasing them ,nothing is stored in memory ,and using SAX parser you can't access element in a random way there is no going back ! , but Dom let you access any part of the xml file since it keeps the whole file/document in memory . hope this answer you question .
如果您想知道哪个最快的解析器 Xerces 将是最快的,您会发现 SAX解析器应该给你比 Dom 更高的性能
if you want to know which fastest parser Xerces is going to be the fastest you'll find and SAX parser should give you more performance than Dom
这篇关于Android:DOM vs SAX vs XMLPullParser 解析?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android:DOM vs SAX vs XMLPullParser 解析?


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