title: Iterate through the elements in JAXB
body: <p>I created a method to unmarshall my xml (item.xml) file .But if there are more than one element ,how can i iterate through all the elements and get them displayed?</p>
  
  <p>My Code is as following :</p>
  
  <pre><code>        final JAXBContext jc = JAXBContext.newInstance("com.generated");
  
          final Unmarshaller u = jc.createUnmarshaller();
  
          final File f = new File("D:\\item.xml");
  
          final JAXBElement element = (JAXBElement) u.unmarshal(f);
  
          final Item item = (Item) element.getValue();
  
          // This will be helpful only if the xml contains one element
          System.out.println(item.getCode());
          System.out.println(item.getName());
          System.out.println(item.getPrice());
  </code></pre>
  
  <p>If my xml is  </p>
  
  <pre><code>       &lt;item&gt;
           &lt;item1&gt;
              &lt;code&gt;12000&lt;/code&gt;
              &lt;name&gt;Samsung Galaxy Tab 620&lt;/name&gt;
              &lt;price&gt;9999&lt;/price&gt;
           &lt;/item1&gt;
           &lt;item2&gt;
              &lt;code&gt;15000&lt;/code&gt;
              &lt;name&gt;NOKIA&lt;/name&gt;
              &lt;price&gt;19999&lt;/price&gt;
           &lt;/item2&gt;
           &lt;item3&gt;
              &lt;code&gt;18000&lt;/code&gt;
              &lt;name&gt;HTC 620&lt;/name&gt;
              &lt;price&gt;29999&lt;/price&gt;
           &lt;/item3&gt;
         &lt;/item&gt;
  </code></pre>
  
  <p>How can i get all the values displayed? Can anyone help me?</p>