Hi, I am trying to create an RSS reader in Visual C # express. I need to read the rss feed into a text box when the form loads. I have never worked with RSS feeds before, and all the examples that I have met are executed in the visual studio, and it seems that I cannot use this:
(XmlReader reader = XmlReader.Create(Url))
This is what I got so far. This does not work.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Net; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { var s = RssReader.Read("http://ph.news.yahoo.com/rss/philippines"); textBox1.Text = s.ToString(); } public class RssNews { public string Title; public string PublicationDate; public string Description; } public class RssReader { public static List<RssNews> Read(string url) { var webResponse = WebRequest.Create(url).GetResponse(); if (webResponse == null) return null; var ds = new DataSet(); ds.ReadXml(webResponse.GetResponseStream()); var news = (from row in ds.Tables["item"].AsEnumerable() select new RssNews { Title = row.Field<string>("title"), PublicationDate = row.Field<string>("pubDate"), Description = row.Field<string>("description") }).ToList(); return news; } }
I'm not sure what to do. Please, help.
source share