扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
System.Net.WebRequest myRequest = System.Net.WebRequest.Create(rssURL); |
System.Net.WebResponse myResponse = myRequest.GetResponse(); |
System.IO.Stream rssStream = myResponse.GetResponseStream(); |
System.Xml.XmlDocument rssDoc = new System.Xml.XmlDocument(); rssDoc.Load(rssStream); |
System.Xml.XmlNodeList rssItems = rssDoc.SelectNodes("rss/channel/item"); |
System.Xml.XmlNode rssDetail; rssDetail = rssItems.Item(i).SelectSingleNode("title"); |
if (rssDetail != null) { title = rssDetail.InnerText; } else { title = ""; } |
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> public void ProcessRSSItem(string rssURL) { System.Net.WebRequest myRequest = System.Net.WebRequest.Create(rssURL); System.Net.WebResponse myResponse = myRequest.GetResponse(); System.IO.Stream rssStream = myResponse.GetResponseStream(); System.Xml.XmlDocument rssDoc = new System.Xml.XmlDocument(); rssDoc.Load(rssStream); System.Xml.XmlNodeList rssItems = rssDoc.SelectNodes("rss/channel/item"); string title = ""; string link = ""; string description = ""; for (int i = 0; i < rssItems.Count; i++) { System.Xml.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("<p><b><a href='" + link + "' target='new'>" + title + "</a></b><br/>"); Response.Write(description + "</p>"); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <% string rssURL = "http://www.codeguru.com/icom_includes/feeds/codeguru/rss-all.xml"; Response.Write("<font size=5><b>Site: " + rssURL + "</b></font><Br />"); ProcessRSSItem(rssURL); Response.Write("<hr />"); rssURL = "http://www.developer.com/icom_includes/feeds/special/dev-5.xml"; Response.Write("<font size=5><b>Site: " + rssURL + "</b></font><Br />"); ProcessRSSItem(rssURL); %> </div> </form> </body> </html> |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者