pub fn to_string_with_namespaces<S: Serialize>(
value: &S,
namespaces: BTreeMap<String, String>,
) -> Result<String, Error>Expand description
A convenience method for serializing some object to a string, with xml namespaces.
ยงExamples
#[derive(Serialize)]
struct Person {
name: String,
age: u32,
}
let mut namespaces = BTreeMap::new();
namespaces.insert("".to_string(), "http://example.com/schema.xsd".to_string());
let joe = Person {name: "Joe".to_string(), age: 42};
// An empty key indicates a global namespace
let serialized = to_string_with_namespaces(&joe, namespaces).unwrap();
println!("{}", serialized);