Originally posted by Vad Fogel:
This might be a newbie question, but I'm curious what is the core difference between JAXP and SAX and when do I want to use each of them to process XML? Also, how thoroughly do you cover XML processing in your book?
SAX is an event-based API for processing XML (the XML parser implementation sends your code events as it goes through the XML document).
DOM is a tree-based API for processing XML (the XML parser constructs a Java object hierarchy from the DOM tree that you can then "interrogate" to get the data you want).
JAXP is an implementation-independent API for parsing XML. In other words, you use the factory classes DocumentBuilderFactory and SAXParserFactory, defined in the JAXP API to obtain some implementation of the corresponding parser interfaces.
I'd suggest browsing the articles at IBM developerWorks. They have some pretty good XML related tutorials there.
Actually, I did some programming with both DOM and SAX, but I've never had exposure to JAXP. What I know is that DOM is more intuitive to work with whereas SAX is more efficient for handling memory intensive XML processing. If I get you right, JAXP can potentially take advantage of the both approaches, is it correct?
My book goes in to great detail about XML, XML Namespace and XML Schema, all of which you need to know for Web services. It also covers JAXP, SAX, and DOM - but that coverage is a bit lighter because I found that Elliotte Rusty Harold's wonderful book, *Processing XML with Java* is just the best reference. In the book I cover the parsers, but point readers to Rusty's book for a more indepth study of SAX, JAXP, DOM, and TrAX.