feed-parser 2.0.0

A simple RSS 1.0 / RSS 2.0 / Atom feed parser
Documentation

English | 日本語

Unit Test crates.io docs.rs

feed-parser reads RSS 1.0, RSS 2.0 and Atom documents into a single Feed type, so the code that consumes a feed does not need to know which format the source publishes. Each format keeps its own parser, and the differences between them — dc:creator, pubDate versus published, Atom's <link> attributes — are normalized on the way in. Malformed input is returned as a ParseError rather than raised as a panic.

Install

cargo add feed-parser

Requires Rust 1.85 or newer.

Quick Start

use feed_parser::parsers::{Feed, rss2};

let rss_data = r#"
<rss version="2.0">
    <channel>
        <title>RSS Title</title>
        <link>http://www.example.com/main.html</link>
        <description>This is an example of an RSS feed</description>
        <item>
            <title>Item 1</title>
            <link>http://www.example.com/item1.html</link>
            <description>Item 1 description</description>
            <pubDate>2024-01-01T23:59:02Z</pubDate>
        </item>
    </channel>
</rss>
"#;

let feeds: Vec<Feed> = rss2::parse(rss_data).unwrap();
assert_eq!(feeds[0].title, "Item 1");
assert_eq!(feeds[0].link, "http://www.example.com/item1.html");
assert_eq!(feeds[0].description.clone().unwrap(), "Item 1 description");

Documentation

  • Usage — the three parsers, the Feed type, and how each format's elements are mapped onto it.
  • Error Handling — every ParseError variant, when each is returned, and how to match on them.
  • Development — build and test commands, repository layout, the MSRV policy, and the release process.
  • Changelog — release notes and the 1.x to 2.0 migration guide.

License

Licensed under the Apache License, Version 2.0. See LICENSE.