CODEFETCH™
            Examples
Cache of Wrox Beginning JSP Code/Chapter 14/XML/iterate.jsp from
http://support.apress.com/1861008317/8317_code.zip
Source code below from:
Beginning Jsp 2.0: Build Web Applications Using Jsp, Java, and Struts
By Ben Galbraith, Peter den Haan, Lance Lavandowska, Sathya Narayana Panduranga, Krishnaraj Perrumal, and Erick Sgarbi
Published February, 2003
Average rating

      Powells     Alibris


<%@ taglib prefix="x"
    uri="http://jakarta.apache.org/taglibs/xtags-1.0" %>

<html>
  <head>
    <title>JSTL XML Support -- Flow Control</title>
  </head>
  <body bgcolor="#FFFFFF">
    <h3>Iterating through an XML document</h3>
    
    <x:parse>
     <items>
      <item>
       <Fruit Name="Apple">Red Apple</Fruit>
      </item>
      <item>
       <Vegetable Name="Okra">Fresh Okra</Vegetable>
      </item>
      <item>
       <Beer Name="Bud">Fine Beer</Beer>
      </item>
      <item>
       <Beer Name="Kingfisher">Lager Beer</Beer>
      </item>
     </items>
    </x:parse>
    
    <!--iterate through all the elements --> 
    <x:forEach select="/items/item">
      <!--print the current element --> 
      ->  <x:valueOf select="." />
      
      <!--check if the selected element has a Beer child element --> 
      <x:if test="./Beer">
        <!--yes it is beer --> 
        * is a Beer
      </x:if>
      <br>
    </x:forEach>
    
  </body>
</html>