SimpleFeedReader is an open-source library written in C# that simplifies the task of reading and parsing syndication feeds.
Syndication feeds, such as RSS and Atom, are a valuable source of online information. These standardized formats allow users to follow the latest updates from websites, blogs, and other web resources without the need to visit them manually.
The SimpleFeedReader library from RobThree allows us to access these feeds easily and efficiently. It facilitates the extraction of key information from the feeds, such as titles, descriptions, links, and publication dates.
It supports RSS 0.9x, 1.0, 2.0, and Atom 1.0 formats, making it a versatile solution for any project requiring the consumption of syndication feeds.
Its API is designed to be intuitive and easy to use, allowing you to start working with feeds in a matter of minutes.
Moreover, most errors are caught, protecting us, for example, from errors that occur if we try to read a badly formatted feed (I have found feeds that experience this temporarily, and then fix themselves). However, we can disable this error catching.
How to use SimpleFeedReader
We can add the library to a .NET project easily, through the corresponding Nuget package.
Install-Package SimpleFeedReader
Here are some examples of how to use SimpleFeedReader extracted from the library’s documentation
var reader = new FeedReader();
var items = reader.RetrieveFeed("http://www.nytimes.com/services/xml/rss/nyt/International.xml");
foreach (var i in items)
Console.WriteLine($"{i.Date.ToString("g")}\t{i.Title}");
Which would give a result similar to this:
4/16/2014 4:27 AM Growth Rose 7.4% in First Quarter, China Reports
4/16/2014 12:29 AM Milan Court Gives Berlusconi a Year of Community Service
4/15/2014 12:34 PM Desalination Plant Said to Be Planned for Thirsty Beijing
4/15/2014 7:24 PM After Prank by Dutch Girl on Twitter, Real Trouble
4/15/2014 4:33 PM Afghanistan Says NATO Airstrike in East Killed Civilians
4/16/2014 12:49 AM Iran Escalates Dispute Over U.N. Envoy
...
Here is another example of how to retrieve a feed and its different properties.
using SimpleFeedReader;
// Create an instance of the feed reader
var reader = new FeedReader();
// Read a syndication feed
var feed = reader.RetrieveFeed("https://example.com/feed.rss");
// Access the elements of the feed
foreach (var item in feed.Items)
{
Console.WriteLine($"Title: {item.Title}");
Console.WriteLine($"Description: {item.Description}");
Console.WriteLine($"Link: {item.Link}");
Console.WriteLine($"Publication Date: {item.PublishDate}");
Console.WriteLine();
}
SimpleFeedReader is Open Source, and all the code and documentation is available in the project’s repository at https://github.com/RobThree/SimpleFeedReader