2021-03-23 12:02:16 +00:00
|
|
|
use std::{error::Error, fs};
|
2020-05-23 12:32:40 +00:00
|
|
|
|
|
|
|
use opml::OPML;
|
|
|
|
|
|
|
|
fn main() -> Result<(), Box<dyn Error>> {
|
|
|
|
let xml = fs::read_to_string("examples/opml_samples/rust_feeds.opml")?;
|
|
|
|
|
2021-03-23 12:02:16 +00:00
|
|
|
let subscriptions = OPML::from_str(&xml)?;
|
2020-05-26 08:28:19 +00:00
|
|
|
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
|