4 releases
0.2.2 | Feb 18, 2019 |
---|---|
0.2.1 | Feb 17, 2019 |
0.2.0 | Jan 26, 2019 |
0.1.0 | Nov 13, 2018 |
#6 in #nest
Used in servedir
7KB
128 lines
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
~255KB