3 releases (breaking)

0.3.0 Jul 12, 2024
0.2.0 Jun 7, 2024
0.1.0 Jun 3, 2024

#1904 in Asynchronous

MIT license

12KB
300 lines

Xml Macro

A convenience macro for use with quick-xml, to save one from its verbosity!

Example usage:

use xml_macro::xml;
use std::io::Cursor;
use quick_xml::Writer;

// Create the event
let event = xml!(<person name="Josh"
                         occupation={
                             let arr = ["a", "b", "c"];
                             arr[2]
                         }>);

// Write said event
let mut writer = Writer::new(Cursor::new(Vec::new()));
writer.write_event(event).unwrap();

// Check it matches our expectations
assert_eq!(
    r#"<person name="Josh" occupation="c">"#,
    String::from_utf8(writer.into_inner().into_inner()).unwrap()
)

Alternatively the xmls! macro can be used to generate an array of xml events.

Dependencies

~260–710KB
~17K SLoC