| |
24. 33. 4. 解析XML与XPath表达式 |
|
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
<html>
<head>
<title>xml actions</title>
</head>
<body>
This example parses XML and uses an XPath expression...
<p/>
<c:set var="someXML">
<people>
<person>
<name>Mark</name>
<age>30</age>
</person>
<person>
<name>Ruth</name>
<age>29</age>
</person>
</people>
</c:set>
<x:parse var="parsedDocument" xml="${someXML}" />
Here is a list of people:
<ul>
<x:forEach select="$parsedDocument/people/person">
<li> <x:out select="name" /> </li>
</x:forEach>
</ul>
</body>
</html>
|
|
Download: JSTLParseXMLWithXPathexpression.zip( 5,143 k) |
|