17 unstable releases (7 breaking)

0.8.2 Nov 14, 2025
0.8.1 Jun 1, 2025
0.8.0 May 3, 2025
0.6.0 Aug 31, 2022
0.1.2 Mar 20, 2017

#139 in Encoding

Download history 327170/week @ 2026-03-20 330070/week @ 2026-03-27 306953/week @ 2026-04-03 336705/week @ 2026-04-10 309581/week @ 2026-04-17 339636/week @ 2026-04-24 326257/week @ 2026-05-01 342558/week @ 2026-05-08 358272/week @ 2026-05-15 313759/week @ 2026-05-22 390932/week @ 2026-05-29 419630/week @ 2026-06-05 384723/week @ 2026-06-12 332447/week @ 2026-06-19 340872/week @ 2026-06-26 316474/week @ 2026-07-03

1,449,390 downloads per month
Used in 1,138 crates (368 directly)

MIT license

155KB
4.5K SLoC

serde-xml-rs

Rust

xml-rs based serializer and deserializer for Serde (compatible with 1.0)

Example usage

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);
}

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.

Dependencies

~0.5–1.2MB
~24K SLoC