JSP Displaying a Subset in XML : XML « JSP « Java






JSP Displaying a Subset in XML


/*
<people>
  <person>
    <name>Peter</name>
    <age>54</age>
  </person>
  <person>
    <name>Patricia</name>
    <age>50</age>
  </person>
</people>

*/


<%@ taglib uri="http://java.sun.com/jstl/xml"  prefix="x" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<html >
  <head>
    <title>Displaying a Subset</title>
  </head>

  <body>
    <c:import url="http://localhost:8080/chapter02/people.xml"
              var="inputDoc" />

    <x:parse  xml = "${inputDoc}"
              var = "parsedDoc" />

    Here is a list of people over the age of 45:
    <ul>
      <x:forEach select="$parsedDoc/people/person/name[../age > 45]"
                 var="currentName" >
        <li><x:out select="." />
      </x:forEach>
    </ul>
  </body>
</html>


           
       








Related examples in the same category

1.Using the Core XML tags
2.XML transformation
3.Performing XSL Transformations
4.JSP in pure XML generating conforming XHTML
5.XSLT In JSP
6.XSLT in JSP 2
7.JSP Parsing using the DOM
8.JSP Parsing using JDOM
9.JSP Parsing using the DOM and JSTL
10.JSP and SAX
11.JSP XML and XSLT transform
12.JSP List of data in the XML document
13.Deal With XML In JSP