Alex Rivera | Logout

Deserializing an RSS feed in .NET

Asked 2009-08-29T01:30:37.763
11

Is it practical / possible to use serialization to read data from an RSS feed? I basically want to pull information from my Netflix queue (provided from an RSS feed), and I'm trying to decide if serialization is feasible / possible, or if I should just use something like XMLReader. Also, what would be the best way to download the feed from a URL? I've never pulled files from anything but drives, so I'm not sure how to go about doing that.

Edit
Report

1 Answer

4
using System.ServiceModel.Syndication;

public static SyndicationFeed GetFeed(string uri)
    {
        if (!string.IsNullOrEmpty(uri))
        {
            var ff = new Rss20FeedFormatter(); // for Atom you can use Atom10FeedFormatter()
            var xr = XmlReader.Create(uri);
            ff.ReadFrom(xr);
            return ff.Feed;             
        }
        return null;
    }
answered 2011-10-04T07:47:18.360

Your Answer