I have heard a lot about XML parser but I want to know i.e 2 kinds of it a开发者_开发问答nd also the advantages and disadvantages of each one! please help me thanks
There's a nice article comparing Sax vs Dom
XML parsers.
- Sax: very fast and works for huge documents but the API is less intuitive as it is event based
- Dom: slower and more memory consuming because the whole XML needs to be loaded into memory but the API is very easy to use.
Kind of a broad question. I suppose the two main approaches are DOM and SAX parsers.
DOM parsers create an in-memory tree of nodes for the document. Very easy to use for the programmer, but could be too much overhead for large documents.
SAX parsers read through the document once and create a stream of events like "tag started". It is up the programmer to do useful things with these events. More efficient, but more difficult to use.
There are two more worth investigating:
1.StaX: easier to use than SAX http://www.xml.com/pub/a/2003/09/17/stax.html
2.VTD-XML: faster and leaner than DOM http://java.dzone.com/articles/introduction-vtd-xml
精彩评论