XMLBeam: Java library to project parts of a XML DOM tree into Java objects via XPath instead of using data binding

xmlbeam image

I haven’t tried this, but it looks interesting. It seems to be designed to
help break the dependency between the XML structure and the structure of your
code. With most data binding libraries, you either make your api mirror the
structure of the XML, or you transform the data to match your API. This lets
you map data from the XML directly onto Java objects using XPath and
annotations.

Take a look at the XMLBeam introduction page.

Sample from the website:

Access XML data directly via XPath-annotated Java interfaces:

<xml>
   <example>
      <content type="foo" >bar</content>
   </example>
</xml>

public interface Example {

    @XBRead("/xml/example/content")
    String getContent();

    @XBRead("/xml/example/content/@type")
    String getType();

}