Java Tutorial/JSP/XML Path
Версия от 17:44, 31 мая 2010; (обсуждение)
JSTL XML Path Select
Code for Jsp page
<%@ taglib uri="http://java.sun.ru/jstl/core" prefix="c" %><%@ taglib uri="http://java.sun.ru/jstl/xml" prefix="x" %>
<html>
<head>
<title>Out Examples</title>
</head>
<body>
<c:import var="students" url="students.xml" />
<x:parse var="doc" xml="${students}" />
<table border="1">
<tr>
<td>$doc/students/student/name/first</td>
<td>
<x:out select="$doc/students/student/name/first" />
</td>
</tr>
<tr>
<td>$doc/students/student[@id=1]/name/first</td>
<td>
<x:out
select="$doc/students/student[@id=1]/name/first" />
</td>
</tr>
<tr>
<td>$doc/students/student[@id=2]/name/first</td>
<td>
<x:out
select="$doc/students/student[@id=2]/name/first" />
</td>
</tr>
</table>
</body>
</html>