Edi.SyndicationFeed.ReaderWriter 2.3.0

dotnet add package Edi.SyndicationFeed.ReaderWriter --version 2.3.0                
NuGet\Install-Package Edi.SyndicationFeed.ReaderWriter -Version 2.3.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Edi.SyndicationFeed.ReaderWriter" Version="2.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Edi.SyndicationFeed.ReaderWriter --version 2.3.0                
#r "nuget: Edi.SyndicationFeed.ReaderWriter, 2.3.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Edi.SyndicationFeed.ReaderWriter as a Cake Addin
#addin nuget:?package=Edi.SyndicationFeed.ReaderWriter&version=2.3.0

// Install Edi.SyndicationFeed.ReaderWriter as a Cake Tool
#tool nuget:?package=Edi.SyndicationFeed.ReaderWriter&version=2.3.0                

Edi.SyndicationFeed.ReaderWriter

.NET Build and Pack

The original repo https://github.com/dotnet/SyndicationFeedReaderWriter was archived long time ago. I created this repo to continue maintain the project.

Edi.SyndicationFeed.ReaderWriter (original Microsoft.SyndicationFeed.ReaderWriter) provides lightweight forward-only read/write APIs (similar to .NET XmlReader) to simplify operations with RSS 2.0 (spec) and Atom (spec) syndication feeds. It offers extensiblity to support custom feed elements and formatting. The workflow is async on demand, which enables this library to be used on syndication feeds of arbitrary size or stream latency.

Requirements:

Supports:

  • .NET 6.0
  • .NET 8.0

Building:

  • The solution will build in Visual Studio 2022 after cloning.

Running Tests:

  • Open the solution in Visual Studio 2022.
  • Build the Tests project.
  • Open the Test Explorer and click "Run All" or run each test individually.

Examples

Examples can be found here.

Create an RssReader and Read a Feed

using (var xmlReader = XmlReader.Create(filePath, new XmlReaderSettings() { Async = true }))
{
    var feedReader = new RssFeedReader(xmlReader);

    while(await feedReader.Read())
    {
        switch (feedReader.ElementType)
        {
            // Read category
            case SyndicationElementType.Category:
                ISyndicationCategory category = await feedReader.ReadCategory();
                break;

            // Read Image
            case SyndicationElementType.Image:
                ISyndicationImage image = await feedReader.ReadImage();
                break;

            // Read Item
            case SyndicationElementType.Item:
                ISyndicationItem item = await feedReader.ReadItem();
                break;

            // Read link
            case SyndicationElementType.Link:
                ISyndicationLink link = await feedReader.ReadLink();
                break;

            // Read Person
            case SyndicationElementType.Person:
                ISyndicationPerson person = await feedReader.ReadPerson();
                break;

            // Read content
            default:
                ISyndicationContent content = await feedReader.ReadContent();
                break;
        }
    }
}

Create an RssWriter and Write an Rss Item

var sw = new StringWriterWithEncoding(Encoding.UTF8);

using (XmlWriter xmlWriter = XmlWriter.Create(sw, new XmlWriterSettings() { Async = true, Indent = true }))
{
    var writer = new RssFeedWriter(xmlWriter);
      
    // Create item
    var item = new SyndicationItem()
    {
        Title = "Rss Writer Avaliable",
        Description = "The new Rss Writer is now available as a NuGet Package!",
        Id = "https://www.nuget.org/packages/Microsoft.SyndicationFeed.ReaderWriter",
        Published = DateTimeOffset.UtcNow
    };

    item.AddCategory(new SyndicationCategory("Technology"));
    item.AddContributor(new SyndicationPerson("test", "test@mail.com"));

    await writer.Write(item);
    xmlWriter.Flush();
}

class StringWriterWithEncoding : StringWriter
{
    private readonly Encoding _encoding;

    public StringWriterWithEncoding(Encoding encoding)
    {
        this._encoding = encoding;
    }

    public override Encoding Encoding {
        get { return _encoding; }
    }
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Edi.SyndicationFeed.ReaderWriter:

Package Downloads
Drammer.Integration.Rss

RSS reader used in the Drammer whisky app.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Edi.SyndicationFeed.ReaderWriter:

Repository Stars
EdiWang/Moonglade
Blog system of https://edi.wang, runs on Microsoft Azure
Version Downloads Last updated
2.3.0 933 11/13/2024
2.2.0 2,602 12/2/2023
2.1.0 422 11/15/2023
2.0.2 466 10/11/2023
2.0.1 1,069 6/13/2023
2.0.0 205 6/12/2023