SAX解析器,XPath中,DOM,XMLPullParser:之间的差异 [英] The difference among : SAX Parser,XPath,DOM,XMLPullParser

查看:310
本文介绍了SAX解析器,XPath中,DOM,XMLPullParser:之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道四种以上类型(SAXPaser,XPath的,DOM XMLPullParse),当我们应该使用的每一个之间的差异。

I want to know the difference between the four above types (SAXPaser, XPath, DOM, XMLPullParse) and when should we use each one.

推荐答案

SAX解析是最好的实现比DOM,请参阅以下这两者之间的区别:

SAX Parsing is the Best one to implement than DOM, see the difference between these two in the following:

DOM

节点都是树结构的形式 内存:它占用更多的内存,DOM是pffered在小型XML文档的情况下,只有$ P $ 在运行速度较慢 存储为对象 编程容易实现 易于导航和使用。

The Nodes are in the form of Tree Structure Memory: It Occupies more memory, DOM is only preffered in the case of small XML documents Slower at runtime Stored as an objects Programmatically easy to implement Ease of navigation and use.

SAX

序 它不使用pferred对大文件的任何内存$ P $。 更快,因为上述观点在运行时。 对象被创建。 需要写code创建对象 在SAX向后导航是不可能的,因为它顺序处理的文件

Sequence of events It doesn't use any memory preferred for large documents. Faster at runtime, because of the above mentioned point. Objects are to be created. Need to write code for creating objects In SAX Backward navigation is not possible as it sequentially processes the document

所以,如果你有非常大的文件,那么你应该使用SAX解析器,因为它会触发事件和释放他们,没有什么是存储在内存中,并使用SAX解析器,你不能访问以随机方式的元素有没有回头路! ,但大教堂让你访问任何部分的XML文件,因为它使整个文件/文件在内存中。

So 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 .

请参阅此文章,你可以得到你想要的东西通过阅读摘要

see this article and you can get what you want by reading the Summary.

还检查该<一href="http://www.developer.com/ws/android/development-tools/Android-XML-Parser-Performance-3824221-2.htm">link查看不同的XML解析器的性能

also check this link to view performance of different xml parser

这篇关于SAX解析器,XPath中,DOM,XMLPullParser:之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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