#xml #html #nest

nestxml

Tools to easily nest XML or HTML elements

1 unstable release

0.1.0 Nov 13, 2018

#39 in #xml

Download history 12/week @ 2018-11-16 3/week @ 2018-11-23 6/week @ 2018-11-30 9/week @ 2018-12-07

1 downloads per month

MIT license

5KB
91 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

extern crate nestxml;
extern crate xml;

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"John\
        <last_name>Doe</last_name></contacts>"[..]);
}

Dependencies

~188KB