using System; using System.IO; using System.Net; using System.Text; using DataStreams.Xml; namespace LargeXMLReader { public class DisplayDiggRSS { static void Main(string[] args) { // // // Stories // Stories // 2011-10-05T11:30:29Z // http://services.digg.com/ // // Digg // // // How Magazines Are Adapting to the Mobile Revolution // // Magazine editors discuss early lessons from tablet publishing, and the challenges of extending their content to a proliferating number of tablet sizes and platforms going forward.<img src="http://feeds.feedburner.com/~r/digg/topic/programming/popular/~4/1evIqO7R2kU" height="1" width="1"/> // 2011-10-04T22:14:11Z // // 131 // // // Technology // // // 1 // // // // // // // // // http://digg.com/news/technology/how_magazines_are_adapting_to_the_mobile_revolution // http://digg.com/news/technology/how_magazines_are_adapting_to_the_mobile_revolution?utm_campaign=Feed%3A+http%3A%2F%2Fservices.digg.com%2F&utm_medium=feed&utm_source=diggapi // ... // HttpWebRequest request = HttpWebRequest.Create( "http://feeds.digg.com/digg/topic/programming/popular.rss") as HttpWebRequest; using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) using (Stream responseStream = response.GetResponseStream()) using (XmlRecordReader reader = new XmlRecordReader( responseStream, Encoding.UTF8, "atom:feed/atom:entry", LoadMethod.Streaming)) { reader.AddNamespace("digg", "http://digg.com/docs/diggrss/"); reader.AddNamespace("media", "http://search.yahoo.com/mrss/"); reader.AddNamespace("feedburner", "http://rssnamespace.org/feedburner/ext/1.0"); reader.AddNamespace("atom", "http://www.w3.org/2005/Atom"); reader.Columns.Add("atom:title", "title"); reader.Columns.Add("atom:link/@href", "link"); reader.Columns.Add("atom:content", "description"); reader.Columns.Add("atom:updated", "pubDate"); reader.Columns.Add("digg:diggCount", "diggCount"); reader.Columns.Add("digg:category", "category"); reader.Columns.Add("digg:commentCount", "commentCount"); while (reader.ReadRecord()) { Console.WriteLine("title: " + reader["title"]); Console.WriteLine("link: " + reader["link"]); Console.WriteLine("description: " + reader["description"]); Console.WriteLine("pubDate: " + reader["pubDate"]); Console.WriteLine("diggCount: " + reader["diggCount"]); Console.WriteLine("category: " + reader["category"]); Console.WriteLine("commentCount: " + reader["commentCount"]); } } Console.WriteLine("Done."); Console.ReadLine(); } } }