title: How to read an XML file with Multiple group of element without attribute value in Java?
body: <blockquote>
    <p>I basically want to know how to get these element values from the xml
    file in java set it into the Object.</p>
  </blockquote>
  
  <p>Below are the sample XML file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Response&gt;
     &lt;LoanApplication&gt;
        &lt;LoanId&gt;1111&lt;/LoanId&gt;
        &lt;LoanStatus&gt;Unsuccessful&lt;/LoanStatus&gt;
        &lt;LoanReference&gt;111&lt;/LoanReference&gt;
     &lt;/LoanApplication&gt;
     &lt;LoanApplication&gt;
        &lt;LoanId&gt;222&lt;/LoanId&gt;
        &lt;LoanStatus&gt;Unsuccessful&lt;/LoanStatus&gt;
        &lt;LoanReference&gt;333&lt;/LoanReference&gt;
     &lt;/LoanApplication&gt;
     &lt;LoanApplication&gt;
        &lt;LoanId&gt;222&lt;/LoanId&gt;
        &lt;LoanStatus&gt;Unsuccessful&lt;/LoanStatus&gt;
        &lt;LoanReference&gt;4444&lt;/LoanReference&gt;
     &lt;/LoanApplication&gt;
     &lt;LoanApplication&gt;
        &lt;LoanId&gt;555&lt;/LoanId&gt;
        &lt;LoanStatus&gt;Current&lt;/LoanStatus&gt;
        &lt;LoanReference&gt;7777&lt;/LoanReference&gt;
     &lt;/LoanApplication&gt;
     &lt;LoanApplication&gt;
        &lt;LoanId&gt;3333&lt;/LoanId&gt;
        &lt;LoanStatus&gt;Current&lt;/LoanStatus&gt;
        &lt;LoanReference&gt;9999&lt;/LoanReference&gt;
     &lt;/LoanApplication&gt;
  &lt;/Response&gt;   
  </code></pre>
  
  <p>Below are the Class where I want get xml data...</p>
  
  <pre><code>public class LoanIDResponse implements java.io.Serializable
  {
  private Integer loanID;
  private Integer loanReference;
  private String loanStatus;
  
  public LoanIDResponse()
  {
  }
  public void setLoanID(Integer loanID)
  {
      this.loanID = loanID;
  }
  
  public void setLoanStatus(String loanStatus)
  {
      this.loanStatus = loanStatus;
  }
  
  public void setLoanReference(Integer loanReference)
  {
      this.loanReference = loanReference;
  }
  public Integer getLoanID()
  {
      return loanID;
  }
  
  public Integer getLoanReference()
  {
      return loanReference;
  }
  
  public String getLoanStatus()
  {
      return loanStatus;
  }
  }
  </code></pre>
  
  <p>Below are the method where put some effort to parse xml file. Now I am struck how to set in my class setters.</p>
  
  <pre><code> public Set&lt;LoanIDResponse&gt; getLoanIDList()
      {
          Set&lt;LoanIDResponse&gt; loanIDSet = new HashSet&lt;&gt;();
          try
          {
  
              DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
              DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
              Document doc = docBuilder.parse(new File("Response.xml"));
  
              doc.getDocumentElement().normalize();
              NodeList listOfLoanApplication = doc.getElementsByTagName("LoanApplication");
              int totalLoanApplication = listOfLoanApplication.getLength();
  
  
              for (int s = 0; s &lt; listOfLoanApplication.getLength(); s++)
              {
  
                  Node loanApplicationNode = listOfLoanApplication.item(s);
                  if (loanApplicationNode.getNodeType() == Node.ELEMENT_NODE)
                  {
                      LoanIDResponse response = new LoanIDResponse();
                      Element loanApplicationElement = (Element) loanApplicationNode;
  
                      NodeList loanIDList = loanApplicationElement.getElementsByTagName("LoanId");
  
                      NodeList loanReferenceList = loanApplicationElement.getElementsByTagName("LoanReference");
  
                      NodeList loanStatusList = loanApplicationElement.getElementsByTagName("LoanStatus");
  
                  }
  
              }
  
          } catch (SAXParseException err)
          {
              LOGGER.log(Level.WARNING, "** Parsing error" + ", line {0}, uri {1}", new Object[]
              {
                  err.getLineNumber(), err.getSystemId()
              });
              LOGGER.log(Level.WARNING, " {0}", err.getMessage());
  
          }
          return loanIDSet;
      }
  </code></pre>