xmltv 0.9.1

XMLTV for electronic program guide (EPG) parser and generator using serde.
Documentation

xmltv

XMLTV for electronic program guide (EPG) parser and generator using serde.

XMLTV DTD is here: https://github.com/XMLTV/xmltv/blob/master/xmltv.dtd

Usage

use std::str::FromStr;

use quick_xml::de::from_str;
use quick_xml::se::to_string_with_root;
use xmltv::*;

fn main() {
    let xml = "<tv>\
<programme channel=\"1\" start=\"2021-10-09 12:00:00 +0200\" stop=\"2021-10-09 13:00:00 +0200\">\
<title>Les feux de l&apos;amour é</title>\
</programme>\
<programme channel=\"2\" start=\"2021-10-09 12:20:00 +0200\" stop=\"2021-10-09 12:35:00 +0200\">\
<title lang=\"fr-FR\">Le journal</title>\
</programme>\
<programme channel=\"3\" start=\"2021-10-09 13:00:00 +0200\" stop=\"2021-10-09 13:40:00 +0200\">\
<title>Le journal</title>\
</programme>\
</tv>";

    // deserialize into the root object (Tv)
    let item: Tv = from_str(xml).unwrap();

    // serialize into string
    let _out = to_string_with_root("tv", &tv).unwrap();
}

To serialize big files, you can look into tests/from_files.rs::test_programmes_from_files. It reads programmes one by one without loading everything in RAM.

Features

  • Flatten some elements like <new/> to be a boolean in order to avoid boilerplate