Crates.io | xml-macro |
lib.rs | xml-macro |
version | 0.3.0 |
source | src |
created_at | 2024-06-03 17:16:54.354502 |
updated_at | 2024-07-12 16:24:06.465082 |
description | A convenience macro for quick-xml |
homepage | |
repository | https://gitlab.com/john_t/xml-macro |
max_upload_size | |
id | 1260301 |
size | 14,095 |
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.