XML SAX解析器之间的差异,拉解析器和放大器; DOM解析器的android [英] Difference among XML SAX parser, Pull parser & DOM Parser in android

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

问题描述

我想知道什么是XML的 SAX解析器之间的区别,拉解析器和放大器; DOM解析器在Android中。在此条件下,哪一个是在性能和​​实现好?

I want to know what's the difference between XML SAX parser, Pull parser & DOM parser in Android. In which condition, which one is better in performance and implementation?

感谢名单。 Khobaib。

Thanx. Khobaib.

推荐答案

DOM解析器 - 它使用的基于对象的办法。也就是说,它首先加载整个XML在内存中,XML节点转换为对象,然后开始分析他们。因此,它是pretty的慢。

Dom Parser - It uses object based approach. i.e., it first loads the entire XML in memory, converts the XML nodes into objects and then starts parsing them. So, it is pretty slower.

SAX和PULL解析器 - 他们使用基于事件的办法。两者都是在存储器和性能方面几乎相同。但也有对的时候,如下所述使用它们几个显着的情况。

SAX and PULL Parser - they use event based approach. Both are almost same in terms of memory and performance. However there are few distinguishing situations on when to use them as described below.

DOM解析器 - 使用它时,你需要为验证整个XML解析之前。 不要使用它时,XML过大和验证可能会受到影响。 一旦开始分析,它分析从开始节点到结束节点。有没有办法来解析特定的节点。

Dom Parser - Use it when you need to validate the entire XML before parsing. Never use it when the XML is too large and validation can be compromised. Once it starts parsing, it parses from starting node to ending node. there is no way to parse only particular nodes.

SAX - 当你想解析整个XML使用它。 一旦开始分析,它分析从开始节点到结束节点。有没有办法来解析特定的节点。

SAX - Use it when you want to parse the entire XML. Once it starts parsing, it parses from starting node to ending node. there is no way to parse only particular nodes.

PULL - 使用它时,你不想来解析整个XML。这是比较容易实现比SAX,因为你没有保持你的解析器的状态。你可以拉你有兴趣只在一个特定的节点。

PULL - Use it when you don't want to parse the entire XML. It is easier to implement than SAX, because you don't have to maintain the state of your parser. You can pull only a particular node you are interested at.

我的建议是 - 需要的验证 - 去DOM ,文件大小为 或你是不是感兴趣的整个XML的语法分析去的 PULL ,文件大小为 或你需要解析< STRONG>的整个XML 的文件 - 去的 SAX

My suggestion is - Need validation - Go for DOM, File size is small or you are not interested in parsing of entire XML- Go for PULL, File size is large or you need to parse the entire XML file - Go for SAX.

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

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