title: XML Parsing using DOM
body: <p>I have an XML with the following data...</p>
  
  <pre><code>&lt;movies total="3"&gt; 
  &lt;movie cover="9_pro.jpg" Title="A Very " MovieDuration="1.29" showtime="2:50 PM"         theatre="UV3"/&gt;
  &lt;movie cover="5_pro.jpg" Title="Par" MovieDuration="1.24" showtime=" 12:00 PM"     theatre="University Village 3"/&gt;
  &lt;movie cover="8_pro.jpg" Title="PinBts" MovieDuration="1.30" showtime="9:20 PM" theatre="University Village 3"/&gt;
  &lt;/movies&gt;
  </code></pre>
  
  <p>I want to parse this using JDOM parser in a servlet...I have used the following code so far:</p>
  
  <pre><code>    try 
      {
      doc=builder.build(url);     
      Element root = doc.getRootElement();
      List children = root.getChildren();     
      out.println(root);  
  
      for (int i = 0; i &lt; children.size(); i++) 
          {
              Element movieAtt = doc.getRootElement().getChild("movie");      
              //out.println(movieAtt.getAttributeValue( "cover" ));
              out.println(movieAtt.getAttributeValue( "Title" ));
              //out.println(movieAtt.getAttributeValue( "MovieDuration" ));
              //out.println(movieAtt.getAttributeValue( "showtime" ));
              //out.println(movieAtt.getAttributeValue( "theatre" ));
          }   
  
      }
  </code></pre>
  
  <p>However my code returns values for the first child element of root repetitively 3 times. I assume this is because i have all 3 child name as "movie" only. </p>
  
  <p>So i want to distinguish these, and make the count to next movie child with attributes like Title="par" etc..</p>
  
  <p>Been figuring out this since so long but could not find. Help would be really appreciable</p>