https://github.com/rreverser/serde-xml-rs
xml-rs based deserializer for Serde (compatible with 1.0+)
https://github.com/rreverser/serde-xml-rs
deserialization parsing rust serde xml
Last synced: 7 months ago
JSON representation
xml-rs based deserializer for Serde (compatible with 1.0+)
- Host: GitHub
- URL: https://github.com/rreverser/serde-xml-rs
- Owner: RReverser
- License: mit
- Created: 2017-02-16T16:54:58.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-12-07T23:12:27.000Z (about 2 years ago)
- Last Synced: 2025-04-07T08:12:12.645Z (9 months ago)
- Topics: deserialization, parsing, rust, serde, xml
- Language: Rust
- Homepage: https://crates.io/crates/serde-xml-rs
- Size: 134 KB
- Stars: 282
- Watchers: 8
- Forks: 96
- Open Issues: 102
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# serde-xml-rs
[](https://github.com/RReverser/serde-xml-rs/actions/workflows/rust.yml)
`xml-rs` based serializer and deserializer for Serde (compatible with 1.0)
## Example usage
```rust
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#"BananaStore"#;
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);
}
```
## Breaking changes in version 0.8.0
Notably:
- The `$value` name has been changed to `#content` (could become configurable in the future).
- Fields that are deserialized from attributes must now have a name that starts with a `@`. This aligns with what was introduced in the serializer.
See MIGRATION.md for more details, and tips on how to migrate.