使用 DOM 解析器和 SAX 解析器进行 Android XML 解析的区别

发布于 2024-10-08 07:41:17 字数 95 浏览 0 评论 0原文

我想知道使用 DOM 解析器和 SAX 解析器进行 Android XML 解析究竟有什么优势?

是不是 DOM 解析器比 SAX 解析器更有优势,或者反之亦然?

I would like to know what exact advantage is gained in doing Android XML Parsing using DOM Parser and SAX Parser?

Is it like DOM parser is advantageous than SAX Parser or vice-versa?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独享拥抱 2024-10-15 07:41:18

SAX 解析是比 DOM 最好的一种解析方式,两者之间的区别如下:

DOM:

  1. 节点采用树形结构的形式
  2. 内存:占用更多内存,仅在 XML 文档较小的情况下才首选 DOM
  3. 运行时速度较慢
  4. 存储为对象
  5. 以编程方式易于实现
  6. 易于导航和使用。

SAX:

  1. 事件序列
  2. 它不使用大型文档首选的任何内存。
  3. 由于上述这一点,运行时速度更快。
  4. 对象将被创建。
  5. 需要编写代码来创建对象
  6. 在 SAX 中,向后导航是不可能的,因为它顺序处理文档

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

DOM:

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

SAX:

  1. Sequence of events
  2. It doesn't use any memory preferred for large documents.
  3. Faster at runtime, because of the above mentioned point.
  4. Objects are to be created.
  5. Need to write code for creating objects
  6. In SAX Backward navigation is not possible as it sequentially processes the document
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文