1. Нужны два пакета: Jdom.jar и Rome.jar.
2. Создайте проект, и содержание Web.xml выглядит следующим образом:
Кода -копия выглядит следующим образом:
<? xml version = "1.0" Encoding = "UTF-8"?>
<web-app version = "2,5"
xmlns = "http://java.sun.com/xml/ns/javaee"
xmlns: xsi = "http://www.w3.org/2001/xmlschema-instance"
xsi: schemalocation = "http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd ">
<приветственный список>
<welcely-file> index.jsp </werving-file>
</wellow-file-list>
</web-app>
3. Создайте контент index.jsp следующим образом:
Кода -копия выглядит следующим образом:
Скопируйте код следующим образом
<%@page contentype = "text/html"%>
<%@page pageencoding = "utf-8"%>
<html>
<голова>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<название> Sina News </title>
</head>
<тело>
</p> <%
</p> </p> java.util.properties systemsettings = System.getProperties ();
</p> </p> systemsettings.put ("http.proxyhost", "mywebcache.com");
</p> </p> systemsettings.put ("http.proxyport", "8080");
</p> </p> System.SetProperties (SystemsEttings);
</p> </p> string urlstr = "http://rss.sina.com.cn/news/marquee/ddt.xml";
</p> </p> java.net.urlconnection feedurl = new java.net.url (urlstr) .openconnection ();
</p> </p> feedurl.setrequestproperty ("Пользовательский агент",
</p> </p> </p> </p> "mozilla/4.0 (совместимо; msie 5.0; windows nt; digext)");
</p> </p> com.sun.syndication.io.syndfeedinput input = new com.sun.syndication.io.syndfeedinput ();
</p> </p> com.sun.syndication.feed.synd.syndfeed feed = input.build (new com.sun.syndication.io.xmlreader (feedurl));
</p>%>
</p> <div align = "center">
</p> </p> <h1> <%= feed.getTitle ()%> </h1>
</p> </p> <таблица границы = 1 cellpadding = 3>
</p> </p> </p> <tr>
</p> </p> </p> </p> <th> число </th>
</p> </p> </p> </p> <th> title </th>
</p> </p> </p> </p> <th> время www.vevb.com </th>
</p> </p> </p> </p> <Th> Контент </th>
</p> </p> </p> </tr>
</p> </p> </p> <%
</p> </p> </p> </p> java.util.list list = feed.getEntries ();
</p> </p> </p> </p> for (int i = 0; i <list.size (); i ++) {
</p> </p> </p> </p> com.sun.syndication.feed.synchrond.syndentry entry = (com.sun.syndication.feed.synchrond.syndentry) list.get (i);
</p> </p> </p> </p>%>
</p> </p> </p> <tr>
</p> </p> </p> </p> <td> <%= i + 1%> </td>
</p> </p> </p> </p> <td> <a href = "<%= entry.getLink ()%>"> <%= intrint.getTitle ()%> </a> </td>
</p> </p> </p> </p> <td> <%= entry.getPublishedDate ()%> </td>
</p> </p> </p> </p> <td> < %= entry.getDescription (). getValue () %> </td>
</p> </p> </p> </tr>
</p> </p> </p> <%
</p> </p> </p> </p>}
</p> </p> </p>%>
</p> </p> </table>
</p> </div>
</p> <br>
</body>
</html>