xml-rs based deserializer for Serde (compatible with 0.9+)
Use serde_xml_rs::deserialize(...)
on any type that implements std::io::Read
as following:
```rust
extern crate serdexmlrs;
use serdexmlrs::deserialize;
struct Item { pub name: String, pub source: String }
struct Project { pub name: String,
#[serde(rename = "Item", default)]
pub items: Vec<Item>
}
fn itworks() {
let s = r##"
Alternatively, you can use serde_xml_rs::Deserializer
to create a deserializer from a preconfigured xml_rs::EventReader
.
If you have an input of the form <foo abc="xyz">bar</foo>
, and you want to get at thebar
, you can use the special name $value
:
rust
struct Foo {
pub abc String,
#[serde(rename = "$value")]
pub body String,
}
Deserializer tries to be as intuitive as possible.
However, there are some edge cases where you might get unexpected errors, so it's best to check out tests
for expectations.