Obtain the RSS of the website and aggregate it to your webpage!

Source: Internet
Author: User
I want to integrate RSS news from other websites into my own webpage. I have never been learning it. Today we finally succeeded! This method may be a bit stupid! The idea is to download the XML file to the local device and then read the local XML file. That's easy! I don't know if there are any simpler methods. I hope you can give me some advice!
The core code is as follows:
(Use webRequest to get the content of the specified page, and then use FileStream to write it to a local file)
Core part (download the XML file of the RSS link to your local computer !)
 
Private void download_Click (object sender, System. EventArgs e)
             {
Encoding sjis = Encoding. GetEncoding ("UTF-8 ");
FileStream fs = new FileStream (Server. MapPath (".") + "sina. xml", FileMode. Create, FileAccess. Write );
// Create StreamWriter to prepare for writing
StreamWriter rw = new StreamWriter (fs, sjis );
               
String rl;
// Create a WebRequest object
WebRequest myReq = WebRequest. Create ("http://rss.sina.com.cn/news/marquee/ddt.xml"); // read the remote file (Sina news) and save the file locally with FileStream!
// Create a WebResponse object
WebResponse myRes = myReq. GetResponse ();

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.