#xml #html #nest

nestxml

Tools to easily nest XML or HTML elements

4 releases

✓ Uses Rust 2018 edition

0.2.2 Feb 18, 2019
0.2.1 Feb 17, 2019
0.2.0 Jan 26, 2019
0.1.0 Nov 13, 2018

#54 in Template engine

27 downloads per month
Used in 1 crate

MIT license

7KB
128 lines

Documentation Crate MIT license

Purpose

Tools to easily nest XML or HTML elements


lib.rs:

Tools to nest XML or HTML elements. Relies on the xml-rs crate.

Example

use xml::EmitterConfig;

fn main() {
    let out = Vec::new();
    let mut out = EmitterConfig::new()
        .write_document_declaration(false)
        .create_writer(out);
    nestxml::element(&mut out, "contacts").write(|out| {
        nestxml::element(out, "first_name").text("John")?;
        nestxml::element(out, "last_name").text("Doe")
    }).unwrap();
    let out = out.into_inner();
    assert_eq!(&out[..], &b"<contacts><first_name>John</first_name>\
        <last_name>Doe</last_name></contacts>"[..]);
}

Dependencies

~186KB