1 unstable release

0.1.0 Aug 12, 2019

#1186 in Images

Download history 277448/week @ 2026-01-23 344779/week @ 2026-01-30 425832/week @ 2026-02-06 365780/week @ 2026-02-13 274379/week @ 2026-02-20 314446/week @ 2026-02-27 372801/week @ 2026-03-06 360489/week @ 2026-03-13 335722/week @ 2026-03-20 354052/week @ 2026-03-27 395593/week @ 2026-04-03 441909/week @ 2026-04-10 456203/week @ 2026-04-17 491653/week @ 2026-04-24 450764/week @ 2026-05-01 451237/week @ 2026-05-08

1,931,431 downloads per month
Used in 1,179 crates (21 directly)

MIT license

19KB
320 lines

xmlwriter

Build Status Crates.io Documentation

A simple, streaming, partially-validating XML writer that writes XML data into an internal buffer.

Features

  • A simple, bare-minimum, panic-based API.
  • Non-allocating API. All methods are accepting either fmt::Display or fmt::Arguments.
  • Nodes auto-closing.

Example

use xmlwriter::*;

let opt = Options {
    use_single_quote: true,
    ..Options::default()
};

let mut w = XmlWriter::new(opt);
w.start_element("svg");
w.write_attribute("xmlns", "http://www.w3.org/2000/svg");
w.write_attribute_fmt("viewBox", format_args!("{} {} {} {}", 0, 0, 128, 128));
w.start_element("text");
// We can write any object that implements `fmt::Display`.
w.write_attribute("x", &10);
w.write_attribute("y", &20);
w.write_text_fmt(format_args!("length is {}", 5));

assert_eq!(w.end_document(),
"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 128 128'>
    <text x='10' y='20'>
        length is 5
    </text>
</svg>
");

License

MIT

No runtime deps