Simple RSS reader

Source: Internet
Author: User

RSS (relly Simple Syndication) is a format used to describe and synchronize website content. It is currently the most widely used XML application. RSS builds a platform for rapid dissemination of information, which enables everyone to become a potential information provider. After an RSS file is published, the information contained in this RSS feed can be directly called by other sites, and because the data is in a standard XML format, it can also be used by other terminals and servers.

 

Using System;
Using System. Collections. Generic;
Using System. LINQ;
Using System. Web;
Using System. Web. UI;
Using System. Web. UI. webcontrols;
Using System. net;
Using System. IO;
Using System. xml;

Public Partial ClassDefault2: system. Web. UI. Page
{
Protected VoidPage_load (ObjectSender, eventargs E)
{

}< br> protected void btn_yd_click ( Object sender, eventargs E)
{< br> string url = txt_url.text;

//Send a URI request
Webrequest request = webrequest. Create (URL );
//Get URI response
Webresponse response = request. getresponse ();
//Get Response stream
Stream stream = response. getresponsestream ();

// Use an xmldocument object to store XML content in the stream
Xmldocument xdoc = New Xmldocument ();
// Xdoc. normalize ();
// Load a specified document from a specified stream
Xdoc. Load (Stream );
// Item Node Set
Xmlnodelist xnl = xdoc. selectnodes ( " RSS/channel/item " );

//Instantiate the item element entity class in RSS
Rssmodel item;
Ilist <rssmodel> items =NewList <rssmodel> ();

For (Int I = 0 ; I <xnl. Count; I ++)
{
Item = New Rssmodel ();
Xmlnode XN;
Xn = xnl. Item (I). selectsinglenode ( " Title " );
If (XN! = Null )
{
Item. Title = xn. innertext;
}

Xn = xnl. Item (I). selectsinglenode ("Link");
If(XN! =Null)
{
Item. Link = xn. innertext;
}

Xn = xnl. Item (I). selectsinglenode ( " Description " );
If (XN! = Null )
{
Item. Description = xn. innertext;
}
Items. Add (item );
}
Gridview1.datasource = items;
Gridview1.databind ();
}
}

 

Download source code

 

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.