RSS-Feeds lesen mit .NET Framework 3.5

Written on August 05, 2007

Wie leicht das Lesen eines RSS-Feeds mit .NET Framework 3.5 (Beta 2) ist, zeigt der folgende Code:

using System;
using System.Collections.Generic;
using System.ServiceModel.Syndication;
using System.ServiceModel.Web;
using System.Linq;
using System.Text;
using System.Xml;

namespace ConsoleApplication1 {
    class Program {
        static void Main(string[] args) {
            Rss20FeedFormatter rssSerializer = new Rss20FeedFormatter();
            XmlReader reader = XmlReader.Create(@"http://blog.alexonasp.net/SyndicationService.asmx/GetRss");
            SyndicationFeed feed = rssSerializer.ReadFrom(reader);
            foreach (SyndicationItem item in feed.Items) {
                Console.WriteLine(item.Title.Text);
            }
            Console.ReadLine();
        }
    }
}

Das Resultat: