ASP. NET to read RSS, asp.net to read rss

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.