2 releases
new 0.0.1 | Apr 16, 2025 |
---|---|
0.0.0 | Apr 9, 2025 |
#58 in #started
146 downloads per month
Used in xmlity-quick-xml
145KB
3.5K
SLoC
XMLity

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 primairly 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.
Get started
To get started, we recommend you check out the XMLity book and the documentation.
Example
- Add XMLity and XMLity-compatible (de)serializer library. In this example we use
xmlity-quick-xml
.
[dependencies]
xmlity = { version = "0.0.1", features = ["derive"] }
xmlity-quick-xml = "0.0.1"
- Write defintions and use:
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);
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Dependencies
~235–740KB
~17K SLoC