Reputation: 34451
I've been using JDOM for general XML parsing for a long time, but get the feeling that there must be something better, or at least more lightweight, for Java 5 or 6.
There's nothing wrong with the JDOM API, but I don't like having to include Xerces with my deployments. Is there a more lightweight alternative, if all I want to do is read in an XML file or write one out?
Upvotes: 6
Views: 5710
Reputation: 4792
There was recently a fork of JDOM for java 5 called coffeeDOM. You should check it out.
Upvotes: 2
Reputation: 403501
The best lightweight alternative is, in my opinion, XOM, but JDOM is still a very good API, and I see no reason to replace it.
It doesn't have a dependency on Xerces, though (at least, it doesn't need the Apache Xerces distro, it works alongside the Xerces that's packaged into the JRE).
Upvotes: 6
Reputation: 484
I would like to think JAXP is a good choise for you. It's standard, included in JDK, it provides clear interface and allows to hook up any implementations.. If all what you need in is to read and write not very large and overcomplicated xml files, JAXP DOM api embedded in JDK will cover you requirements.
Upvotes: 0
Reputation: 206846
Use one of the XML APIs that come standard with Java, so that you don't have to include any third-party libraries.
XML in the Java Platform Standard Edition (Java SE) 6
Upvotes: 0
Reputation: 144
JDOM is very good and simple. There has been many new ways to parse XML after release of JDOM, but those has have different focus than simplicity. JAXB makes things simple in some cases when you have well known XML document has your schema does not get updated daily basis. New push parsers are very good and even mandatory for very large XML files (hundreds of MBs). Speed benefit for SAX parser can be ten fold.
Upvotes: 0
Reputation: 12901
I've used the javax.xml.stream package (XMLStreamReader/XMLStreamWriter) to read and write XML using xml pull/push techniques. It's worked for me so far.
Upvotes: 3
Reputation: 54705
You should check out Commons Digester (see the answer I've given here). It provides a very lightweight mechanism for parsing XML.
Upvotes: 0
Reputation: 30448
We use JAXB - it generates the classes based on the schema. You can generate your files without a schema, and just annotate how you want the xml to be.
Upvotes: 2