In case you want to quickly develop a XML parser in Java I recommend using JAXB. It creates Java classes from xsd schemas and vice versa automatically.

Set up Eclipse for JAXB

Since I am often working in an environment where I cannot use just any software I need, it is interesting to know what needs to be done in Eclipse before you can start using JAXB.

It is pretty simple. All you need to do is installing the plugins under category "Web, XML, Java EE and OSGi Enterprise Development" available in the release repository of your current Eclipse version.  

To do so select Help -> Install New Software... from the eclipse main menu bar.

 

In the Installation wizard, select the repository site for your current version of Eclipse and wait until the contents of the repository have been loaded. This might take some time.

In this example I am connecting to the release repository for Eclipse version Luna.

http://download.eclipse.org/releases/luna

 

Select the overall category in order to install all available plugins from the web tools platform project.

After that click Next and follow the instructions of the installation wizard.

How to check if the installation was successful and your Eclipse installation is now supporting JAXB is explained below.

Press Ctrl. + N (or go to File -> New -> Other...) in order to open the wizard chooser and type in "JAXB".

You should see three new options.

  • JAXB Classes form Schema
  • JAXB Project
  • Schema from JAXB Classes

 

Et voila ... However you might experience some issues with JAXB and Java 8 (private machine). On Java 1.7 (clients machine) I did not have any issues.

Resources

Below links might be of interest when dealing with JAXB.

A good tutorial on JAXB, although I have to admit that I only read the first pages, got bored and wandered of doing my own thing. And yes, ... I swore a lot and returned to the page to at least finish the Hello World example ;0).

https://jaxb.java.net/tutorial/

Here we have some interesting stuff on XML Namespaces. Do not try to dodge this one, it is important to understand.

http://www.oracle.com/technetwork/articles/srivastava-namespaces-092580.html

http://blog.bdoughan.com/2010/08/jaxb-namespaces.html

Even just as important as Namespaces is this little hint of a JAXB guru. What do you do if the other programmer did not equip his XML with a namespace. The article under the URL below describes how to deal with XML that does not provide a namespace. There is an even nicer solution, which I still have to publish but I cannot find the link at the moment.

http://blog.bdoughan.com/2012/11/applying-namespace-during-jaxb-unmarshal.html#more

Anyway, hope it helps.