title: Get elements of SOAP response
body: <p>When I send a <code>SOAP request</code> using <code>SAAJ API</code>, I would receive a large <code>SOAP response</code>, in which I need to search for some nodes. </p>
  
  <p>I am using following code but it just show the name of first node of body (<code>HotelListResponse</code> which has many children) and I have noticed that the loop just iterates once, (as shown in commented section). </p>
  
  <p><em>In short: I need to know how to search for some nodes (preferably by their name) in a variable which its type is SOAPMessage. Thanks</em></p>
  
  <pre><code>SOAPMessage sm = response;   //this is the response
  
  sm.writeTo(System.out);    //response is shown successfully in console
  
  SOAPBody ReBody = sm.getSOAPBody();
  Iterator sentIt = ReBody.getChildElements(); //create an iterator on elements
  int counter=0;
  
  while(sentIt.hasNext())
  {
    SOAPBodyElement sentSBE = (SOAPBodyElement)sentIt.next();
    Iterator sentIt2 = sentSBE.getChildElements();
    SOAPElement sentSE = (SOAPElement)sentIt2.next();
  
  
     String sentID = sentSE.getNodeName();  //result is HotelListResponse
     counter++;  
    //System.out.println("sentID:"+sentID);
  }
  System.out.println("counter"+counter); //result is 1
  </code></pre>