Difference between Dom parser and Xerces Parser

六月ゝ 毕业季﹏ 提交于 2019-12-06 09:32:18

Xerces is a DOM parser. It's the Apache implementation in Java or C++.

The two you want to think about are SAX and DOM. DOM creates an object tree in memory; SAX does not. You can manipulate the object tree after the DOM is done parsing; SAX uses an event model to process XML on the fly.

Either SAX or DOM will "work". Your choice is usually based on whether or not you'll keep it in memory to manipulate it or process it in place. If the XML stream is gigabytes, you might not be able to store it all at once. In that case, SAX is a good choice because you can work with it on the fly as you parse.

Google is your friend: Fire it up to learn about DOM4J and JDOM.

I'd recommend JDOM if you're writing Java. It takes care of a lot of the boilerplate stuff.

there are two ways to parse an xml file in Xerces.viz SAX & DOM. SAX Parser:

  1. Event based model.
  2. Serial access (flow of events).
  3. Low memory usage (only events are generated).
  4. To process parts of the document (catching relevant events).
  5. To process the document only once.
  6. Backward navigation is not possible as it sequentially processes the document.
  7. Objects are to be created.

DOM Parser:

  1. (Object based)Tree data structure.
  2. Random access (in-memory data structure).
  3. High memory usage (the document is loaded into memory).
  4. To edit the document (processing the in-memory data structure).
  5. To process multiple times (document loaded in memory).
  6. Ease of navigation.
  7. Stored as objects.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!