# X.Web.RSS [![Sponsor on GitHub](https://img.shields.io/badge/Sponsor_on_GitHub-ff7f00?logo=github&logoColor=white&style=for-the-badge)](https://github.com/sponsors/a-gubskiy) [![Subscribe on X](https://img.shields.io/badge/Subscribe_on_X-000000?logo=x&logoColor=white&style=for-the-badge)](https://x.com/andrew_gubskiy) [![NuGet Downloads](https://img.shields.io/nuget/dt/X.Web.RSS?style=for-the-badge&label=NuGet%20Downloads&color=004880&logo=nuget&logoColor=white)](https://www.nuget.org/packages/X.Web.RSS) X.Web.RSS is a .NET library designed for generating and managing RSS feeds. It provides an easy-to-use API for creating and manipulating RSS feed elements, making it simple to integrate RSS functionality into .NET applications. ## W3C Validation RSS feeds which generated by this library successfully pass W3C validation. You can test your RSS feeds at http://validator.w3.org/feed. ## ⚠️Breaking changes This version contain some important breaking changes: * Serialization logic was moved to `RssDocumentSerializer` class. * `RssDocument` and all other entities converted from `class` to `record`. ## Usage example To read a foreign RSS feed you need to get a stream with RSS data and deserialize it using `RssDocumentSerializer`. ```csharp using System.IO; using System.Text; // read RSS XML from a stream and deserialize using var reader = new StreamReader(stream, Encoding.UTF8); var xml = reader.ReadToEnd(); var serializer = new RssDocumentSerializer(); RssDocument? rss = serializer.Deserialize(xml); Assert.AreEqual("Example", rss?.Channel.Title); ``` To serialize a `RssDocument` back to XML: ```csharp var serializer = new RssDocumentSerializer(); string xml = serializer.Serialize(rssDocument); ``` ### RSS object creating example Complete RSS object will look like this (updated to match current types and constructors): ```csharp using System.Collections.Generic; using System.Globalization; return new RssDocument { Channel = new RssChannel { // RssLink has a constructor that accepts a string URL AtomLink = new RssLink("http://atomlink.com") { Rel = Rel.self, Type = "text/plain" }, Category = "category", Cloud = new RssCloud { Domain = "domain", Path = "path", Port = 1234, Protocol = Protocol.xmlrpc, RegisterProcedure = "registerProcedure" }, Copyright = "copyrignt (c)", Description = "long description", Image = new RssImage { Description = "Image Description", Height = 100, Width = 100, Link = new RssUrl("http://image.link.url.com"), Title = "title", Url = new RssUrl("http://image.url.com") }, Language = new CultureInfo("en").Name, LastBuildDate = new DateTime(2011, 7, 17, 15, 55, 41), Link = new RssUrl("http://channel.url.com"), ManagingEditor = "managingEditor@mail.com (manager)", PubDate = new DateTime(2011, 7, 17, 15, 55, 41), Rating = "rating", SkipDays = new List { Day.Thursday, Day.Wednesday }, SkipHours = new List { new Hour(22), new Hour(15), new Hour(4) }, TextInput = new RssTextInput { Description = "text input desctiption", Link = new RssUrl("http://text.input.link.com"), Name = "text input name", Title = "text input title" }, Title = "channel title", TTL = 10, WebMaster = "webmaster@mail.example.com (webmaster)", Items = new List { new RssItem { Author = "item.author@mail.example.com (author)", Category = new RssCategory { Domain = "category domain value", Text = "category text value" }, Comments = new RssUrl("http://rss.item.comment.url.com"), Description = "item description", Enclosure = new RssEnclosure { Length = 1234, Type = "text/plain", Url = new RssUrl("http://rss.item.enclosure.type.url.com") }, Link = new RssUrl("http://rss.item.link.url.com"), PubDate = new DateTime(2011, 7, 17, 15, 55, 41), Title = "item title", Guid = new RssGuid { IsPermaLink = false, Value = "guid value" }, Source = new RssSource { Url = new RssUrl("http://rss.item.source.url.com") } } } } }; ```