title: How to map an XML to Java objects by XPaths?
body: <p>Given the XML example:</p>
  
  <pre><code>&lt;fooRoot&gt;
    &lt;bar&gt;
      &lt;lol&gt;LOLOLOLOL&lt;/lol&gt;
    &lt;/bar&gt;
    &lt;noob&gt;
      &lt;boon&gt;
        &lt;thisIsIt&gt;&lt;/thisIsIt&gt;
      &lt;/boon&gt;
    &lt;/noob&gt;
  &lt;/fooRoot&gt;
  </code></pre>
  
  <p>Which should be mapped to:</p>
  
  <pre><code>class MyFoo {
    String lol;
    String thisIsIt;
    Object somethingUnrelated;
  }
  </code></pre>
  
  <p>Constraints:</p>
  
  <ul>
  <li>XML should not be transformed, it is provided as a parsed org.w3c.dom.Document object.</li>
  <li>Class does not and will not map 1:1 to the XML.</li>
  <li>I'm only interested to map specific paths of the XML to specific fields of the object.</li>
  </ul>
  
  <p>My dream solution would look like:</p>
  
  <pre><code>@XmlMapped
  class MyFoo {
  
    @XmlElement("/fooRoot/bar/lol")
    String lol;
  
    @XmlElement("/noob/boon/thisIsIt")
    String thisIsIt;
  
    @XmlIgnore
    Object somethingUnrelated;
  }
  </code></pre>
  
  <p>Does anything likewise exists? What I've found either required a strict 1:1 mapping (e.g. JMX, JAXB) or manual iteration over all fields (e.g. SAX, Commons Digester.)</p>
  
  <p><a href="http://jibx.sourceforge.net/index.html" rel="nofollow">JiBX binding definitions</a> come the nearest to what I'm lokking for. However, this tool is ment to marshall/unmarshall complete hierarchy of Java objects. I only would like to extract parts of an XML document into an existing Java bean at runtime.</p>