我有一个可以正常工作的 RSS 提要。我正在尝试使用我已有的代码添加另一个项目“dc:date”,我怎样才能使它工作?另外,由于某种原因,我在标题之后生成了一个额外的段落行,不知道为什么。
public partial class _Default : System.Web.UI.Page
{
protected void ProcessRSSItem(string rssURL)
{
WebRequest myRequest = System.Net.WebRequest.Create("http://feeds.feedburner.com/HIGHTIMESMagazine");
WebResponse myResponse = myRequest.GetResponse();
Stream rssStream = myResponse.GetResponseStream();
XmlDocument rssDoc = new XmlDocument();
rssDoc.Load(rssStream);
XmlNodeList rssItems = rssDoc.SelectNodes("rss/channel/item");
string title = "";
string link = "";
string description = "";
for (int i = 0; i < 3 && i < rssItems.Count; i++)
{
XmlNode rssDetail;
rssDetail = rssItems.Item(i).SelectSingleNode("title");
if (rssDetail != null)
{
title = rssDetail.InnerText;
}
else
{
title = "";
}
rssDetail = rssItems.Item(i).SelectSingleNode("link");
if (rssDetail != null)
{
link = rssDetail.InnerText;
}
else
{
link = "";
}
rssDetail = rssItems.Item(i).SelectSingleNode("description");
if (rssDetail != null)
{
description = rssDetail.InnerText;
}
else
{
description = "";
}
Response.Write("<h6><b><a href='"+ link +"'target='new'>" + title + "</a></b></h6>");
Response.Write("<p>" + description + "</P>");
}
}
}