Mega Code Archive

 
Categories / Java / JSP
 

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>