title: Pulling XML child inner node from XML to Java Object using JAXB
body: <p>I have been trying to pull a child node from an XML which I received from a SOAP as string. I can retrieve the parent node but couldn't retrieve the child node. I also surf the internet to see if I can get an answer but all to no avail. I saw some examples with direct child pulling, but that didn't solve my problem.</p>
  
  <pre><code>&lt;response&gt;
    &lt;code&gt;1&lt;/code&gt;
    &lt;list available="2"&gt;
       &lt;cart id="2" name="egg"&gt;
          &lt;stuff&gt;
             &lt;id&gt;001&lt;/id&gt;
             &lt;name&gt;Crew&lt;/name&gt;
             &lt;shortname&gt;C&lt;/shortname&gt;
          &lt;/stuff&gt;
       &lt;/cart&gt;
       &lt;cart id="4" name="bread"&gt;
          &lt;stuff&gt;
             &lt;id&gt;004&lt;/id&gt;
             &lt;name&gt;Bread&lt;/name&gt;
             &lt;shortname&gt;B&lt;/shortname&gt;
          &lt;/stuff&gt;
       &lt;/cart&gt;
    &lt;/list&gt;
  &lt;/response&gt;
  </code></pre>
  
  <p>Response Class</p>
  
  <pre><code>public class Response {
     private String code;
     private String list;
     private String cart;
     private Response.Stuff stuffs;
  
  
     @XmlElement(name="code")
     public String getCode() {
       return code;
     }
  
     public void setCode(String code) {
       this.code = code;
     }
     .
     .
    @XmlElement
    public Response.Stuff getStuff() {
      return this.stuffs;
    }
  
    public void setStuff(Response.Cart stuff) {
      this.stuffs = stuff;
    }
  
   public static class Stuff {
     private List&lt;Stuff&gt; stuff;
  
     public List&lt;Stuff&gt; getStuff() {
       if (stuff == null) {
          stuff = new ArrayList&lt;Stuff&gt;();
       }
     return stuff;
    }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Stuff Classs</p>
  
  <pre><code>public class Stuff {
    private String id;
    private String crew;
  
   @XmlElement
   public String getId() {
    return this.id;
   }
  
   public void setId(String id) {
    this.id = id;
   }
   .
   .
  </code></pre>
  
  <p>}</p>
  
  <p>Now my problem is how to pull child stuff content (i.e id,name and shortname) using JAXB.
   I created class Response and Stuff and made stuff a list inside response but when ever I run the code it throws null exception.</p>
  
  <p>PS: Please remember the XML is not a file its a string and am using <code>StringReader</code> class for the <code>JAXB.unmarshal</code></p>