[][src]Crate opml

This crate provides an API to parse and construct OPML files to and from regular Rust structs.

Getting Started

Parsing

use opml::OPML;

let xml = r#"<opml version="2.0"><body><outline text="Outline"/></body></opml>"#;
let parsed = OPML::new(xml).unwrap();

println!("{:#?}", parsed);

Constructing

use opml::{Head, OPML};

let mut opml = OPML::default();
opml
  .add_feed("Rust Blog", "https://blog.rust-lang.org/feed.xml")
  .add_feed(
    "Inside Rust",
    "https://blog.rust-lang.org/inside-rust/feed.xml",
  )
  .set_head(Head {
    title: Some("Rust Feeds".to_string()),
    ..Head::default()
  });

let xml = opml.to_xml().unwrap();
println!("{}", xml);

// Outputs (without whitespace):
// <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>

License

Open-sourced with either the

at your option.

The samples located in tests/spec_samples were taken from the OPML 2.0 spec and are subject to their own license.

Structs

Body

The <body> child element of <opml>. Contains all the <outlines>.

Head

The <head> child element of <opml>. Contains the metadata of the OPML document.

OPML

The top-level <opml> element.

Outline

The <outline> element.