JSP Parsing using the DOM and JSTL : XML « JSP « Java






JSP Parsing using the DOM and JSTL

/*

<people>
  <person>
    <name>Joe</name>
    <age>30</age>
  </person>
  <person>
    <name>Rob</name>
    <age>29</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>Parsing using the DOM and JSTL</title></head>
  <body>
    <c:import url="http://localhost:8080/chapter11/people.xml"
              var="personXml" />
    <x:parse xml="${personXml}" varDom="parsedXml" />

    <h1>List of people</h1>
    <table border="1">
      <tr><th>Name</th><th>Age</th></tr>

      <x:forEach select="$parsedXml/people/person" var="currentPerson">
      <tr>
        <x:forEach select="*">
          <td><x:out select="." /></td>
        </x:forEach>
      </tr>
      </x:forEach>
    </table>
  </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 and SAX
10.JSP Displaying a Subset in XML
11.JSP XML and XSLT transform
12.JSP List of data in the XML document
13.Deal With XML In JSP