#atom #feed #parser #parsing

atom_syndication

Library for serializing the Atom web content syndication format

19 releases

0.6.0 May 30, 2018
0.5.8 Feb 13, 2018
0.5.7 Jan 27, 2018
0.5.6 Nov 28, 2017
0.1.1 May 22, 2015

#34 in Parser implementations

Download history 21/week @ 2018-08-21 55/week @ 2018-08-28 88/week @ 2018-09-04 65/week @ 2018-09-11 44/week @ 2018-09-18 49/week @ 2018-09-25 136/week @ 2018-10-02 86/week @ 2018-10-09 93/week @ 2018-10-16 50/week @ 2018-10-23 27/week @ 2018-10-30 190/week @ 2018-11-06 90/week @ 2018-11-13

224 downloads per month
Used in 6 crates (5 directly)

MIT/Apache

103KB
1.5K SLoC

atom

Build Status Crates.io Status

Library for serializing the Atom web content syndication format.

Documentation

Usage

Add the dependency to your Cargo.toml.

[dependencies]
atom_syndication = "0.5"

The package includes a single crate named atom_syndication.

extern crate atom_syndication;

Reading

A feed can be read from any object that implements the BufRead trait or using the FromStr trait.

use std::fs::File;
use std::io::BufReader;
use atom_syndication::Feed;

let file = File::open("example.xml").unwrap();
let feed = Feed::read_from(BufReader::new(reader)).unwrap();

let string = "<feed></feed>";
let feed = string.parse::<Feed>().unwrap();

Writing

A feed can be written to any object that implements the Write trait or converted to an XML string using the ToString trait.

Note: Writing a feed does not perform any escaping of XML entities.

Example

use std::fs::File;
use std::io::{BufReader, sink};
use atom_syndication::Feed;

let file = File::open("example.xml").unwrap();
let feed = Feed::read_from(BufReader::new(file)).unwrap();

// write to the feed to a writer
feed.write_to(sink()).unwrap();

// convert the feed to a string
let string = feed.to_string();

Invalid Feeds

As a best effort to parse invalid feeds atom_syndication will default elements declared as "required" by the Atom specification to an empty string.

License

Licensed under either of

at your option.

Dependencies

~3.5MB
~69K SLoC