If you see in my new project, there is going to be a lot of XML processing. So I was wondering what would be the better approach to parse the XML files with JAVA. After some R&D I came across a very nicely written API's for parsing the XML and you can go back and forth to get any node since each entity in xml file has been considered as object, so no more restrictions.Yes, I am talking about JDOM. It also comes with very good utility class to process xml using XPath. The static methods provided by class org.jdom.xpath.XPath are pretty straight forward and simple to use in one line :
Listlist = XPath.selectNodes(context, "//root"); Object obj = XPath.selectSingleNode(context, "//root");This will return you the list/Element of matching node(s) as a object. So when I were trying this first time I just started with downloading JDOMv1.1.1.jar from the web.But unfortunately I got stuck with the this wierd exception
java.lang.NoClassDefFoundError: org/jaxen/JaxenException .... So solution is: putting the jdom jar itself not resolve this problem.Since JDOM uses "Jaxen engine" for XPath processing you need to add one more jar called jaxen.jar along with it from here.