xml-macro

Crates.ioxml-macro
lib.rsxml-macro
version0.2.0
sourcesrc
created_at2024-06-03 17:16:54.354502
updated_at2024-07-12 16:24:06.465082
descriptionA convenience macro for quick-xml
homepage
repositoryhttps://gitlab.com/john_t/xml-macro
max_upload_size
id1260301
size12,181
John Toohey (greenfierydragon)

documentation

README

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.

Commit count: 6

cargo fmt