2020-05-23 12:32:40 +00:00
|
|
|
use opml::OPML;
|
|
|
|
|
2022-10-02 19:54:15 +00:00
|
|
|
const SAMPLE: &str = r#"<opml version="2.0">
|
|
|
|
<head>
|
|
|
|
<title>Rust Feeds</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<outline text="Rust Blog" xmlUrl="https://blog.rust-lang.org/feed.xml" />
|
|
|
|
<outline text="Inside Rust" xmlUrl="https://blog.rust-lang.org/inside-rust/feed.xml" />
|
|
|
|
</body>
|
|
|
|
</opml>"#;
|
2020-05-23 12:32:40 +00:00
|
|
|
|
2022-10-02 19:54:15 +00:00
|
|
|
/// Run this example using `cargo run --example rss`.
|
|
|
|
///
|
|
|
|
/// Output:
|
|
|
|
/// Rust Feeds
|
|
|
|
/// ──────────
|
|
|
|
/// Rust Blog https://blog.rust-lang.org/feed.xml
|
|
|
|
/// Inside Rust https://blog.rust-lang.org/inside-rust/feed.xml
|
|
|
|
fn main() {
|
|
|
|
let subscriptions = OPML::from_str(SAMPLE).unwrap();
|
2020-05-23 12:32:40 +00:00
|
|
|
|
2022-10-02 19:54:15 +00:00
|
|
|
if let Some(title) = subscriptions.head.and_then(|head| head.title) {
|
|
|
|
println!("{}", title);
|
|
|
|
println!("{}", "-".repeat(title.len()));
|
|
|
|
}
|
2020-05-23 12:32:40 +00:00
|
|
|
|
|
|
|
for outline in subscriptions.body.outlines {
|
2022-10-02 19:54:15 +00:00
|
|
|
println!("{}\t{}", outline.text, outline.xml_url.unwrap());
|
2020-05-23 12:32:40 +00:00
|
|
|
}
|
|
|
|
}
|