opml/opml_api/examples/rss.rs

28 lines
670 B
Rust
Raw Normal View History

2020-05-23 12:32:40 +00:00
use std::error::Error;
use std::fs;
use opml::OPML;
fn main() -> Result<(), Box<dyn Error>> {
let xml = fs::read_to_string("examples/opml_samples/rust_feeds.opml")?;
let subscriptions = OPML::new(&xml)?;
let head = subscriptions.head.unwrap();
let title = head.title.unwrap();
2020-05-23 12:32:40 +00:00
println!(" {}", title);
println!(" {}", "".repeat(title.len()));
for outline in subscriptions.body.outlines {
println!(" {}\t{}", outline.text, outline.xml_url.unwrap());
}
Ok(())
}
// Output:
// Rust Feeds
// ──────────
// Rust Blog https://blog.rust-lang.org/feed.xml
// Inside Rust https://blog.rust-lang.org/inside-rust/feed.xml