Which XML Parser Do You Recommend?
tshieh asks: "I'm trying to add XML-configurability to a Java application, and I'm trying to figure out which XML parser I should use. Any thoughts on whether I would be better off using Xerces, expat, XML4J, or JDOM (or any others)? So far, I've decided to use DOM rather than SAX since I've heard that DOM is easier to use and I don't anticipate my configuration file becoming so large that the slower and more memory-intensive DOM parsing becomes an issue."
SAX is really simple to use. You write event handlers, where an event is something like "start of document", "end of foobar tag", etc.
If you can write your application using the SAX event model, then you'd find DOM too complex. DOM is good when you need the entire document as a tree structure, e.g. to do some analysis.
If you use SAX, and you find yourself writing a lot of code to remember what you've seen, then you should probably consider DOM. If you can look at each tag or data item once and then forget about it, SAX is the way to go.
Says it all. I've used them all, and in My experience Xerces is relaible, as fast as any, and has the right license.
I'm old enough to remember when discussions on Slashdot were well informed.
We've been using it at work and are happy with it so far.
How to solve most of our problems: 1.Lots of nuclear plants. 2.Cure aging.
Personally, i find SAX easier to use than DOM..
It also takes a whole lot less memory and time to parse than the DOM approach.
We process XML files that can be up to 10MB in size, and DOM parsing these files brings my 500MHz P3 to its knees (yes i have increased the JVM heap size)
Parsing with SAX, however, has proved simple, clean and easy with no performance problems at all.
If youre definitely wanting to use the DOM, try NanoXML.. its much smaller that Xerces and the like, and is perfect for parsing config files etc., as will as being small enough (6KB or so) for client-side and embedded use.
However, for an all-round, no compromise XML parsing solution, then Xerces is pretty good.
I gots ta ding a ding dang my dang a long ling long