title: Unmarshall XML String using Java
body: <p>Hi I am writing a unmarshalling script for an XML response string using java. I have mentioned the xml response, unmarshalling code and the error i received.
  Please help in fixing the issue and also advise me on the problem.</p>
  
  <pre><code>JAXBContext jaxbContext = JAXBContext.newInstance(Customer.class);
  javax.xml.bind.Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
  Customer customer = (Customer) jaxbUnmarshaller.unmarshal(new StreamSource(new     StringReader(response.toString() ) ) );
  System.out.println(customer.getNAME());
  
  
  Exception in thread "main" javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"response"). Expected elements are &lt;{}customer&gt;
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;response&gt;
    &lt;control&gt;
          &lt;status&gt;success&lt;/status&gt;
          &lt;senderid&gt;XXXX&lt;/senderid&gt;
          &lt;controlid&gt;ControlIdHere&lt;/controlid&gt;
          &lt;uniqueid&gt;false&lt;/uniqueid&gt;
          &lt;dtdversion&gt;3.0&lt;/dtdversion&gt;
    &lt;/control&gt;
    &lt;operation&gt;
          &lt;authentication&gt;
                &lt;status&gt;XXXX&lt;/status&gt;
                &lt;userid&gt;XXXX&lt;/userid&gt;
                &lt;companyid&gt;XXXXXX&lt;/companyid&gt;
                &lt;sessiontimestamp&gt;2014-08-12T03:49:00-07:00&lt;/sessiontimestamp&gt;
          &lt;/authentication&gt;
          &lt;result&gt;
                &lt;status&gt;success&lt;/status&gt;
                &lt;function&gt;readByQuery&lt;/function&gt;
                &lt;controlid&gt;testControlId&lt;/controlid&gt;
                &lt;data listtype="customer" count="26" totalcount="26" numremaining="0"&gt;
                      &lt;customer&gt;
                            &lt;RECORDNO&gt;15&lt;/RECORDNO&gt;
                            &lt;CUSTOMERID&gt;RIC001&lt;/CUSTOMERID&gt;
                            &lt;NAME&gt;XYZ&lt;/NAME&gt;
                            &lt;ENTITY&gt;CRIC001&lt;/ENTITY&gt;
                            &lt;PARENTKEY&gt;&lt;/PARENTKEY&gt;
                            &lt;PARENTID&gt;&lt;/PARENTID&gt;
                            &lt;PARENTNAME&gt;&lt;/PARENTNAME&gt;
                         &lt;/customer&gt;
              &lt;customer&gt;
                            &lt;RECORDNO&gt;15&lt;/RECORDNO&gt;
                            &lt;CUSTOMERID&gt;RIC001&lt;/CUSTOMERID&gt;
                            &lt;NAME&gt;BBB&lt;/NAME&gt;
                            &lt;ENTITY&gt;CRIC001&lt;/ENTITY&gt;
                            &lt;PARENTKEY&gt;&lt;/PARENTKEY&gt;
                            &lt;PARENTID&gt;&lt;/PARENTID&gt;
                            &lt;PARENTNAME&gt;&lt;/PARENTNAME&gt;
                         &lt;/customer&gt;
                                        &lt;/data&gt;
          &lt;/result&gt;
    &lt;/operation&gt;
  </code></pre>
  
  <p></p>