Mega Code Archive

 
Categories / Java Tutorial / JSTL
 

Use JSTL to output and extract XML element with 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 uses XPath and the x:out action to extract the     user's name from a piece of XML.     <p/>     <c:set var="someXML">       <person>         <name>Ruth</name>         <age>29</age>       </person>     </c:set>     <x:parse var="parsedDocument" xml="${someXML}" />     The person's name is <x:out select="$parsedDocument//name" />    </body> </html>