RssFeedGenerator

Created: 2015-02-19 22:08
Updated: 2018-03-31 03:11
License: mit

README.md

RssFeedGenerator

Build status NuGet Version NuGet Downloads

Generator of RSS feed xml file.

Example of usage

Here is example of typical using of library:

Rss rss = new Rss();
rss.Channel.Categories = new List<Category>
{
    new Category { Domain = "http://www.some-domain.com", Name = "Category1" },
    new Category { Domain = "http://www.some-domain2.com", Name = "Category2" }
};
rss.Channel.Cloud = new Cloud { Domain = "rpc.sys.com", Path = "/RPC2", Port = 80, Protocol = "xml-rpc", RegisterProcedure = "myCloud.rssPleaseNotify" };
rss.Channel.Copyright = "Copyright 2013, T-Alex Software";
rss.Channel.Description = "Some description";
rss.Channel.Docs = "http://some-site.com/news/rss/";
rss.Channel.Generator = "Some program";
rss.Channel.Image = new Image { Description = "Some description", Link = "http://www.image-url.com", Title = "Image Title", Url = "http://www.image-url.com/image.png" };
rss.Channel.Language = new CultureInfo("en-us").ToString();
rss.Channel.LastBuildDate = new DateTime(2013, 05, 11);
rss.Channel.Link = "http://www.some-site.com";
rss.Channel.ManagingEditor = "some@email.com";
rss.Channel.PublicationDate = new DateTime(2013, 04, 11);
rss.Channel.SkipDays = new List<DayOfWeek> { DayOfWeek.Monday, DayOfWeek.Sunday };
rss.Channel.SkipHours = new List<int> { 3, 5, 18 };
rss.Channel.TextInput = new TextInput { Description = "Some desc", Name = "Input", Title = "Button", Link = "http://some-link.com" };
rss.Channel.Title = "Rss title";
rss.Channel.TTL = 30;
rss.Channel.WebMaster = "webmaster@mail.com";

rss.Channel.Items.Add(new Item { PublicationDate = new DateTime(1990, 05, 24), Author = "Author name", Comments = "http://www.some-site.com/comments", Title = "Item title", Description = "Some desc", Guid = new Models.Guid("5"), Link = "http://www.some-url/item.html", Enclosure = new Enclosure { Url = "http://www.some-url/image.png", Length = 846, Type = "images/png" }, Source = new Source { Url = "http://www.source.com", Name = "Source name" }, Categories = new List<Category> { new Category { Domain = "http://some-url.com/category1", Name = "Category1" }, new Category { Domain = "http://some-url.com/category2", Name = "Category2" } } });
rss.Channel.Items.Add(new Item { PublicationDate = new DateTime(1990, 04, 24), Author = "Author name2", Comments = "http://www.some-site.com/comments2", Title = "Item title2", Description = "Some desc2", Guid = new Models.Guid("7") { IsPermaLink = false }, Link = "http://www.some-url/item2.html", Enclosure = new Enclosure { Url = "http://www.some-url/image2.jpg", Length = 47762, Type = "images/jpg" }, Source = new Source { Url = "http://www.source2.com", Name = "Source name 2" }, Categories = new List<Category> { new Category { Domain = "http://some-url.com/category3", Name = "Category3" }, new Category { Domain = "http://some-url.com/category4", Name = "Category4" } } });

MemoryStream output = new MemoryStream();

RssFeedGenerator.Generate(rss, output);

Output:

<?xml version=""1.0""?>
<rss xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" version=""2.0"">
  <channel>
    <title>Rss title</title>
    <description>Some description</description>
    <link>http://www.some-site.com</link>
    <language>en-US</language>
    <copyright>Copyright 2013, T-Alex Software</copyright>
    <managingEditor>some@email.com</managingEditor>
    <webMaster>webmaster@mail.com</webMaster>
    <pubDate>Thu, 11 Apr 2013 00:00:00 +0300</pubDate>
    <lastBuildDate>Sat, 11 May 2013 00:00:00 +0300</lastBuildDate>
    <category domain=""http://www.some-domain.com"">Category1</category>
    <category domain=""http://www.some-domain2.com"">Category2</category>
    <generator>Some program</generator>
    <docs>http://some-site.com/news/rss/</docs>
    <cloud domain=""rpc.sys.com"" port=""80"" path=""/RPC2"" registerProcedure=""myCloud.rssPleaseNotify"" protocol=""xml-rpc"" />
    <ttl>30</ttl>
    <image>
      <url>http://www.image-url.com/image.png</url>
      <title>Image Title</title>
      <link>http://www.image-url.com</link>
      <description>Some description</description>
    </image>
    <textInput>
      <title>Button</title>
      <description>Some desc</description>
      <name>Input</name>
      <link>http://some-link.com</link>
    </textInput>
    <skipHours>
      <hour>3</hour>
      <hour>5</hour>
      <hour>18</hour>
    </skipHours>
    <skipDays>
      <day>Monday</day>
      <day>Sunday</day>
    </skipDays>
    <item>
      <title>Item title</title>
      <link>http://www.some-url/item.html</link>
      <description>Some desc</description>
      <author>Author name</author>
      <category domain=""http://some-url.com/category1"">Category1</category>
      <category domain=""http://some-url.com/category2"">Category2</category>
      <comments>http://www.some-site.com/comments</comments>
      <enclosure url=""http://www.some-url/image.png"" length=""846"" type=""images/png"" />
      <guid>5</guid>
      <pubDate>Thu, 24 May 1990 00:00:00 +0300</pubDate>
      <source url=""http://www.source.com"">Source name</source>
    </item>
    <item>
      <title>Item title2</title>
      <link>http://www.some-url/item2.html</link>
      <description>Some desc2</description>
      <author>Author name2</author>
      <category domain=""http://some-url.com/category3"">Category3</category>
      <category domain=""http://some-url.com/category4"">Category4</category>
      <comments>http://www.some-site.com/comments2</comments>
      <enclosure url=""http://www.some-url/image2.jpg"" length=""47762"" type=""images/jpg"" />
      <guid isPermaLink=""false"">7</guid>
      <pubDate>Tue, 24 Apr 1990 00:00:00 +0300</pubDate>
      <source url=""http://www.source2.com"">Source name 2</source>
    </item>
  </channel>
</rss>

Get it on NuGet!

Install-Package TAlex.RssFeedGenerator

License

TAlex.RssFeedGenerator is under the MIT license.

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more