woxml

Crates.iowoxml
lib.rswoxml
version0.4.0
created_at2025-07-23 10:19:14.702456+00
updated_at2025-08-20 10:28:27.079141+00
descriptionwrite only xml
homepagehttp://github.com/stepkun/woxml.git
repositoryhttps://github.com/stepkun/woxml.git
max_upload_size
id1764587
size49,279
Stephan Kunz (stepkun)

documentation

https://docs.rs/woxml

README

woxml::XmlWriter

The XmlWriter is designed to write xml in an efficient way without any DOM or other intermediate structures.

The implementation is based on the crate xml_writer by Piotr Zolnierek, but can also be used in 'no_std' environments (use 'default-features = false').

It is not an exact drop-in-replacement for xml_writer's XmlWriter as the access to interiors is prohibitet, you have to use different constructors and accessors respectively. It also is not yet possible to use it for all 'std::io::Write' implementors, missing ones can be added in future versions.

It works for:

  • Vec
  • bytes::BytesMut

Usage

extern crate woxml;
use woxml::XmlWriter;

let mut xml = XmlWriter::pretty_mode(Vec::new()); // supply a woxml::Write implementor
xml.begin_elem("root");
    xml.comment("have a nice day");
    xml.begin_elem("first");
        xml.attr_esc("name", "\"123\"");
        xml.attr("id", "abc");
        xml.text("'text'");
    xml.end_elem();
    xml.begin_elem("stuff");
        xml.cdata("some cdata");
    xml.end_elem();
    xml.set_namespace("area51");
        xml.comment("in namespace 'area51'");
        xml.elem("first");
    xml.unset_namespace();
xml.end_elem();
xml.close(); // This will also close all open elements
xml.flush();

let actual = xml.into_inner();
println!("{}", str::from_utf8(&actual).unwrap())

License

Licensed under either of

at your option.

Contribution

Any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.

Commit count: 0

cargo fmt