Socket
Book a DemoInstallSign in
Socket

AtomFeed

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

AtomFeed

Atom Feed (RSS) library for .NET Framework.

Source
nugetNuGet
Version
1.3.0
Version published
Maintainers
2
Created
Source

AtomFeed

latest version downloads tests status license

The Atom Syndication Format is an XML language used for web feeds.

This project is a .NET implement of Atom 1.0.

Features

  • Serialize atom feed into XML document
  • Deserialize atom feed from XML
  • Follows and conforms to W3C Atom feed validation
  • Supports .NET 8 and .NET 9, Native AOT compatible
  • Zero dependencies

Get Started

You may want to learn about the Atom from the links below:

Most of the modern feed readers support Atom.

You can use this library to build a feed server, or build an app to handle Atom feeds.

Installation

dotnet add package AtomFeed

Usage

Basic usage

Serialize:

using AtomFeed;
using AtomFeed.Element;

var feed = new Feed
{
    Id = "urn:uuid:" + Guid.NewGuid().ToString(),
    Title = "My Blog Feed",
    Updated = DateTimeOffset.UtcNow,
    Entries =
    [
        new Entry
        {
            Id = "urn:uuid:" + Guid.NewGuid().ToString(),
            Title = "My First Article",
            Updated = DateTimeOffset.UtcNow
        }
    ]
};

var xmlDocument = Atom.Serialize(feed);

Deserialize:

using AtomFeed;

const string xml =
    """
    <?xml version="1.0" encoding="utf-8"?>
    <feed xmlns="http://www.w3.org/2005/Atom">
        <id>urn:uuid:01931011-954d-71ee-ade5-0146811ae69f</id>
        <title>Sample Feed</title>
        <updated>2024-11-09T08:36:48Z</updated>
    </feed>
    """;

var feed = Atom.Deserialize(xml);

Strict mode in deserialization

Normally, the strict mode is disabled, when the giving feed is invalid, the parser will return null.

If the strict mode is enabled, the parser will throw an exception.

The strict mode can be used to validate the feed, it follows the W3C Atom feed validation.

var xml = string.Empty;

// A System.Data.ArgumentException will be thrown,
// because the feed is empty.
var feed = Atom.Deserialize(xml, true);
const string xml =
    """
    <?xml version="1.0" encoding="utf-8"?>
    <feed xmlns="http://www.w3.org/2005/Atom">
    </feed>
    """;

// A System.Data.ConstraintException will be thrown,
// because the feed <id> tag is missing.
var feed = Atom.Deserialize(xml, true);

See more in the DeserializeStrictModeTests.cs

License

The MIT License

Keywords

Atom

FAQs

Package last updated on 14 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts