Use JSTL to output and extract XML element with XPATH : XML Path « JSTL « Java Tutorial






<%@ 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>
  Download:  JSTLCoutAndXPathExtractXMLElement.zip( 5,143 k)








24.33.XML Path
24.33.1.Output XML with Select Statement
24.33.2.Use ForEach Loop to Select XML Path
24.33.3.Set Variable by Selecting XML Path
24.33.4.Parse XML With XPath Expression
24.33.5.Parse XML and Path Select
24.33.6.Use JSTL to output and extract XML element with XPATH