ASP. NET to read RSS, asp.net to read rss
RSS is very important for websites. This article uses examples to demonstrate how ASP. NET reads RSS for your reference. The specific methods are as follows:
The main function code is as follows:
/// <Summary> /// load RSS /// </summary> /// <param name = "RssUrl"> RSS address </param> /// <param name = "RssCount"> Number of articles to be extracted </param> // <returns> </returns> public string LoadRSS (string RssUrl, int RssCount) {XmlDocument doc = new XmlDocument (); string Rss = ""; if (RssUrl! = "") {Try {doc. load (RssUrl); XmlNodeList nodelist = doc. getElementsByTagName ("item"); XmlNodeList objItems1; int I = 1; if (doc. hasChildNodes) {foreach (XmlNode node in nodelist) {string title = ""; // article title string link = ""; // link string content = ""; // content string createDate = ""; // posting time I + = 1; if (node. hasChildNodes) {objItems1 = node. childNodes; foreach (XmlNode node1 in objItems1) {swit Ch (node1.Name) {case "title": title = node1.InnerText; break; case "link": link = node1.InnerText; break; case "description": content = node1.InnerText; break; case "pubDate": createDate = node1.InnerText; break;} if (title! = "" & Link! = "") Break ;} rss + = "<a href = '" + link + "'target =' _ blank '>" + title + "</a> posted on" + createDate + "
If you are interested, you can test and further improve the instance code described in this article, hoping to help you design ASP. NET programs.
How does ASPNET read online RSS content?
Webclient and other requests can be directly downloaded.
Rss itself is an xml file and can be parsed manually. It is also very simple.
It seems that no ready-made components are currently available.
How does RSS aspnet implement its subscription?
Xml Solution