| Crates.io | serde-xml-rs |
| lib.rs | serde-xml-rs |
| version | 0.8.1 |
| created_at | 2017-02-17 17:40:07.847608+00 |
| updated_at | 2025-06-01 07:38:06.307668+00 |
| description | xml-rs based deserializer for Serde (compatible with 1.0) |
| homepage | |
| repository | https://github.com/RReverser/serde-xml-rs |
| max_upload_size | |
| id | 8556 |
| size | 448,519 |
xml-rs based serializer and deserializer for Serde (compatible with 1.0)
use serde::{Deserialize, Serialize};
use serde_xml_rs::{from_str, to_string};
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct Item {
name: String,
source: String,
}
fn main() {
let src = r#"<?xml version="1.0" encoding="UTF-8"?><Item><name>Banana</name><source>Store</source></Item>"#;
let should_be = Item {
name: "Banana".to_string(),
source: "Store".to_string(),
};
let item: Item = from_str(src).unwrap();
assert_eq!(item, should_be);
let reserialized_item = to_string(&item).unwrap();
assert_eq!(src, reserialized_item);
}
Notably:
$value name has been changed to #content (could become configurable in the future).@. This aligns with what was introduced in the serializer.See MIGRATION.md for more details, and tips on how to migrate.