Lately, I’ve been working hard on this blog. In a recent post about automating your blog with GitHub actions, I wrote a small .NET Core application that could process my RSS feed. In this post, I will show you how to do just that. Also, if you’re interested, you should check out my BlogPromoter project on GitHub. Let’s get started.

The Code

The first step is to install the System.ServiceModel.Syndication package.

dotnet add package System.ServiceModel.Syndication

Once we install the package, we need the following lines in our code. First, we need the using statement.

using System.ServiceModel.Syndication;

Followed by loading and processing the feed.

var url = "https://khalidabuhakmeh.com/feed.xml";
using var reader = XmlReader.Create(url);
var feed = SyndicationFeed.Load(reader);

Once we have the feed loaded, we can query each syndicated item.

var post = feed
    .Items
    .FirstOrDefault();

Here are some of the properties we can access from each instance of a SyndicationItem class.

  • Authors
  • Categories
  • Content
  • Contributors
  • Copyright
  • Publish Date
  • Links

There you have it. One package and two lines of code will have you processing any RSS feed in no time at all. I hope you enjoyed this post, and thank you for reading.