<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Sina News</title>
</head>
<body>
<%
java.util.Properties systemSettings = System.getProperties();
systemSettings.put("http.proxyHost", "mywebcache.com");
systemSettings.put("http.proxyPort", "8080");
System.setProperties(systemSettings);
String urlStr = "http://rss.sina.com.cn/news/marquee/ddt.xml";
java.net.URLConnection feedUrl = new java.net.URL(urlStr).openConnection();
feedUrl.setRequestProperty("User-Agent",
"Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
com.sun.syndication.io.SyndFeedInput input = new com.sun.syndication.io.SyndFeedInput();
com.sun.syndication.feed.synd.SyndFeed feed = input.build(new com.sun.syndication.io.XmlReader(feedUrl));
%>
<div align="center">
<h1><%=feed.getTitle()%></h1>
<table border=1 cellpadding=3 width="700">
<tr>
<th>Number</th>
<th>Title</th>
<th>Time</th>
<th>Content</th>
</tr>
<%
java.util.List list = feed.getEntries();
for (int i = 0; i < list.size(); i++) {
com.sun.syndication.feed.synd.SyndEntry entry = (com.sun.syndication.feed.synd.SyndEntry) list.get(i);
%>
<tr>
<td><%=i + 1%></td>
<td><a href="<%=entry.getLink()%>"><%=entry.getTitle()%></a></td>
<td><%=entry.getPublishedDate()%></td>
<td><%=entry.getDescription().getValue() %></td>
</tr>
<%
}
%>
</table>
</div>
<br>
</body>
</html>
|