java & xml spaghetti

 
There are so many alternatives when it comes to parse XML in Java.  The popular ones being used are JAXP, Xerces2, SAX–> JDOM (higher level)–> JAXB (even higher level).
My personal favoraite for parsing only is dom4j. It supports XPATH like the following:
SAXReader reader = new SAXReader();
Document document = reader.read( url );
List links = document.selectNodes( "//a[@href]" );
String title = document.valueOf( "/head/title" );
Most of time it can do the job to reteriving the value given the path for me. 
http://www-128.ibm.com/developerworks/xml/library/x-injava/index.html
does a perforamance. comparison on XML parser in Java. DOM4J scores pretty high. 
 
Advertisements
This entry was posted in java. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s