JSTL XML Map Value : XML « JSTL « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JavaFX
25.JDK 6
26.JDK 7
27.JNDI LDAP
28.JPA
29.JSP
30.JSTL
31.Language Basics
32.Network Protocol
33.PDF RTF
34.Reflection
35.Regular Expressions
36.Scripting
37.Security
38.Servlets
39.Spring
40.Swing Components
41.Swing JFC
42.SWT JFace Eclipse
43.Threads
44.Tiny Application
45.Velocity
46.Web Services SOA
47.XML
Java » JSTL » XML 




JSTL XML Map Value


<?xml version="1.0" encoding="ISO-8859-1"?>
<students>
   <student id="1">
      <name>
         <first>Joe</first>
         <last>Y</last>
         <middle>T</middle>
      </name>
      <grade>
         <points>99</points>
         <letter>A</letter>
      </grade>
   </student>
   <student id="2">
      <name>
         <first>James</first>
         <last>Todd</last>
         <middle>K</middle>
      </name>
      <grade>
         <points>92</points>
         <letter>B</letter>
      </grade>
   </student>
   <student id="3">
      <name>
         <first>Kate</first>
         <last>Wang</last>
         <middle>A</middle>
      </name>
      <grade>
         <points>72</points>
         <letter>C</letter>
      </grade>
   </student>
   
</students>


///////////////////////////////////////////////////////////////////////////////

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
<html>
  <head>
    <title>Set Examples</title>
  </head>

  <body>
    <c:import var="students" url="students.xml" />

    <x:parse var="doc" xml="${students}" />

    <x:set var="a" select="$doc/students/student/name/first" />

    <x:set var="b"
    select="$doc/students/student[@id=2]/name/first" />

    <x:set var="c"
    select="$doc/students/student[@id=1]/name/first" />

    <table border="1">
      <tr>
        <td>$doc/students/student/name/first</td>

        <td>
          <x:out select="$a" />
        </td>
      </tr>

      <tr>
        <td>$doc/students/student[@id=2]/name/first</td>

        <td>
          <x:out select="$b" />
        </td>
      </tr>

      <tr>
        <td>$doc/students/student[@id=1]/name/first</td>

        <td>
          <x:out select="$c" />
        </td>
      </tr>
    </table>
  </body>
</html>

           
       














JSTL-XML-Map-Value.zip( 6,553 k)
Related examples in the same category
1.JSTL XML Foreach
2.JSTL XML Output
3.JSTL XML Parse
4.JSTL XML XPath
5.JSTL XML XPath Choose
6.JSTL XML XPath Select
7.JSTL XML XPath: Wired New
8.JSTL: parse XML document
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.