There are many pretty good json libs lika GSon. But for XML I know only Xerces/JDOM and both have tedious API. I don\'t like to use unnecessary objects like DocumentFactory,
Dom4J rocks. It's very easy and understandable
Sample Code:
public static void main(String[] args) throws Exception {
final String xml = " "
+ " ";
Document document = DocumentHelper.parseText(xml);
// simple collection views
for (Element element : (List) document
.getRootElement()
.element("foo")
.element("bar")
.elements("baz")) {
System.out.println(element.attributeValue("name"));
}
// and easy xpath support
List elements2 = (List)
document.createXPath("//baz").evaluate(document);
for (final Element element : elements2) {
System.out.println(element.attributeValue("name"));
}
}
Output:
phleem
gumbo
phleem
gumbo