title: How to get a particular element through JAXB xml parsing?
body: <p>I have used JAXB to parse an XML.How to get a particular element(ie a child node) through JAXB xml parsing without parsing that element as node.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
          &lt;Header&gt;
              &lt;From&gt;
              &lt;Credential
                          domain="NetworkId"&gt;&lt;Identity&gt;ANXXXNNN&lt;/Identity&gt;
              &lt;/Credential&gt;
              &lt;/From&gt;
  
              &lt;To&gt;
              &lt;Credential
                          domain="NetworkId"&gt;&lt;Identity&gt;ANNNXXXXXT&lt;/Identity&gt;
              &lt;/Credential&gt;
              &lt;/To&gt;
  
              &lt;To&gt;
              &lt;Credential
                          domain="NetworkId"&gt;&lt;Identity&gt;BNNXXXT&lt;/Identity&gt;
              &lt;/Credential&gt;
              &lt;/To&gt;
          &lt;/Header&gt;
  </code></pre>
  
  <p>I have done unmarshalling like this,It works fine.For performance,I dont want the elements as node.Is there anyother way to do?</p>
  
  <pre><code>Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  dbf.setNamespaceAware(true);
  DocumentBuilder db = dbf.newDocumentBuilder();
      Document doc;
      doc = db.parse(file);
      NodeList node = (NodeList)doc.getElementsByTagName("TO");
  
     JAXBElement&lt;ToType&gt; element =  jaxbUnmarshaller.unmarshal(node.item(0),ToType.class);
  </code></pre>
  
  <p>Object model is like</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "ToType", propOrder = {
      "credential"
  })
  public class ToType {
  
      @XmlElement(name = "Credential", required = true)
      protected CredentialType credential;
  
  
      public CredentialType getCredential() {
          return credential;
      }
  
      public void setCredential(CredentialType value) {
          this.credential = value;
      }
  </code></pre>
  
  <p>}</p>