Hi I have heard a lot about XML parser but I want to know i.e 2 kinds of it and also the advantages and disadvantages of each one! please help me thanks
+3
A:
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.
Darin Dimitrov
2010-02-26 08:34:42
thanks for your answer and the good link!
Johanna
2010-02-26 08:41:22
You forgot one: Writing your own - normally handles only small special cases, usually a nightmare to maintain and extend, and reinvents the wheel! eg: http://thedailywtf.com/Articles/What-Could-Be-Easier-Than-XML.aspx
CuriousPanda
2010-02-26 09:39:43
A:
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.
Thilo
2010-02-26 08:34:48
A:
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
vtd-xml-author
2010-02-26 08:41:03