XOM (XML Object Model) is a tree based java API for processing XML
by taking the best ideas from SAX and DOM. It is simple, fast and easy to use.
This requires the library xom-1.2.7.jar to be in classpath.
The following example shows querying an XML document using XPath expression.
//Reads and parses the XML
Document doc = builder.build(ins);
Node lastNum = doc.query("//RandomNumbers/Number[last()]").get(0);
System.out.println("Last Number : " + lastNum.getValue());
Node lastButOneNum = doc.query("//RandomNumbers/Number[last()-1]").get(0);
System.out.println("Last but one Number : " + lastButOneNum.getValue());
}