Use JSTL to Deal with RSS : RSS « 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>Reading RSS</title>
  </head>

  <body>
    <c:import var="news"
    url="http://www.wired.com/news_drop/netcenter/netcenter.rdf" />

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

    <table border="1" width="100%">
      <tr bgcolor="blue">
        <td align="center">
          <font color="white" size="+2">
            <b>
              <x:out select="$doc/rss/channel/title" />
            </b>
          </font>

          <br />

          <font color="white" size="-2">
            <x:out select="$doc/rss/channel/pubDate" />
          </font>
        </td>
      </tr>

      <tr>
        <td valign="top">
          <x:out select="$doc/rss/channel/description" />
        </td>
      </tr>

      <x:forEach var="story" select="$doc/rss/channel/item">
        <tr bgcolor="blue">
          <td align="center">
            <a href="&lt;x:out select=">"&gt; 
            <font color="white">
              <x:out select="title" />
            </font>
            </a>
          </td>
        </tr>

        <tr>
          <td valign="top">
            <x:out select="description" />
          </td>
        </tr>
      </x:forEach>
    </table>
  </body>
</html>
  Download:  JSTLDealWithRSS.zip( 1,559 k)








24.35.RSS
24.35.1.Use JSTL to Deal with RSS