title: JAXB unmarshalling only a deeply-nested subset of an XML file
body: <p>My application receives a very lengthy XML document, and I would like to use it to populate a Java object.  </p>
  
  <p>However, while there are tons of deeply-nested elements in the XML, I am only interested in a handful of them.  I am also only interested in going from XML-to-Java.  I do not need the capability of marshalling my Java object back into XML.</p>
  
  <p>I would like to use JAXB for this if possible, since my application's dependencies already include Eclipselink MOXy anyway.  However, I'm not sure how to grab only a handful of deeply nested element values.  I looked at the <code>@XmlElementWrapper</code> annotation, and thought about using it to annotate my Java class fields like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>...
  @XmlElementWrapper(name="LEVEL_1/SUBLEVEL_1/YET_ANOTHER_SUBLEVEL")
  @XmlElement(name="STATUS")
  private String statusCode;
  ...
  </code></pre>
  
  <p>However, I don't know if that <code>name</code> attribute is valid.  I don't get that far anyway... the compiler tells me that <code>@XmlElementWrapper</code> can only be used when the member variable is a Collection type.  Most of the fields I'm trying to pull are single values.</p>
  
  <p>I tried skipping the <code>@XmlElementWrapper</code> annotation, and seeing if <code>@XmlElement</code> alone would understand XPath values:</p>
  
  <pre class="lang-java prettyprint-override"><code>...
  @XmlElement(name="LEVEL_1/SUBLEVEL_1/YET_ANOTHER_SUBLEVEL/STATUS")
  private String statusCode;
  ...
  </code></pre>
  
  <p>While this doesn't cause a compile error, it doesn't work either.  At runtime, Eclipselink simply instantiates my object with a <code>null</code> in this field.</p>
  
  <p>Is there something I am missing, or is what I'm trying to do even possible with JAXB at all?</p>