| Crates.io | xmlity |
| lib.rs | xmlity |
| version | 0.0.8 |
| created_at | 2025-04-09 18:11:27.145627+00 |
| updated_at | 2025-07-30 10:06:59.359917+00 |
| description | A (de)serialization library for XML |
| homepage | https://github.com/lukasfri/xmlity |
| repository | https://github.com/lukasfri/xmlity |
| max_upload_size | |
| id | 1627134 |
| size | 217,767 |
XMLity is a (de)serialization library for XML, inspired by Serde and improves upon XML (de)serialization libraries such as yaserde and quick-xml by providing a more flexible API that is more powerful, utilising primarily a trial and error approach to parsing XML. This can inherently be a bit slower than other libraries, but it allows for more complex XML structures to be parsed.
To get started, we recommend you check out the documentation and the examples.
xmlity-quick-xml.[dependencies]
xmlity = { version = "0.0.8", features = ["derive"] }
xmlity-quick-xml = "0.0.8"
extern crate xmlity_quick_xml;
use xmlity::{Serialize, Deserialize};;
#[derive(Serialize, Deserialize)]
#[xelement(name = "name")]
struct Name(String);
#[derive(Serialize, Deserialize)]
#[xelement(name = "age")]
struct Age(u8);
#[derive(Serialize, Deserialize)]
#[xelement(name = "person")]
struct Person {
name: Name,
age: Age,
}
let person = Person {
name: Name("John".to_string()),
age: Age(42),
};
let xml = xmlity_quick_xml::to_string(&person).expect("Failed to serialize");
assert_eq!(xml, r#"<person><name>John</name><age>42</age></person>"#);
let person: Person = xmlity_quick_xml::from_str(&xml).expect("Failed to deserialize");
assert_eq!(person.name.0, "John");
assert_eq!(person.age.0, 42);
serde-xml-rs: Lacking proper namespace support and other features.yaserde: Lacking support for trial-and-error deserialization, a requirement for full coverage of XML schemas.quick-xml(serde feature): Lacking support for namespaces.