to_string

Function to_string 

Source
pub fn to_string<T>(value: &T) -> Result<String>
where T: Serialize + ?Sized,
Expand description

Serializes a value to an XML string.

ยงExample

use serde::Serialize;
use serde_xml::to_string;

#[derive(Serialize)]
struct Person {
    name: String,
    age: u32,
}

let person = Person {
    name: "Alice".to_string(),
    age: 30,
};

let xml = to_string(&person).unwrap();
assert!(xml.contains("<name>Alice</name>"));