pub fn to_string_with_options<T: Facet<'static>>(
value: &T,
options: &SerializeOptions,
) -> Result<String, XmlError>Expand description
Serialize a value of type T to an XML string with custom options.
ยงExample
#[derive(Facet)]
struct Person {
#[facet(xml::attribute)]
id: u32,
#[facet(xml::element)]
name: String,
}
let person = Person { id: 42, name: "Alice".into() };
// Compact output
let xml = to_string_with_options(&person, &SerializeOptions::default())?;
assert_eq!(xml, r#"<Person id="42"><name>Alice</name></Person>"#);
// Pretty output with tabs
let xml = to_string_with_options(&person, &SerializeOptions::default().indent("\t"))?;