Rust serde How deserialize xml "weird" lists?

Hi everyone,
Im trying to deserialize this style of xml list that are not technically a list but behaves like one:

<list>
    <id-00001>
        <name type="string">Pedro</name>
        <age type="number">37</age>
    </id-00001>
    <id-00002>
        <name type="string">Alex</name>
        <age type="number">30</age>
    </id-00002>
<list>

The number of items on the "list" is variable and will only increment the number(x) on the id-0000x.

The issue is that i cant think how to map this to a Rust struct using serde.

Im trying to do something like this:


#[derive(Debug, Default, Deserialize)]
#[serde(rename = "list")]
List{
    people: Vec<Person>
}

#[derive(Debug, Default, Deserialize)]
Person {
    name: String,
    age: u8
}

but i dont know how to deal with the this tags id-0000x.

Edit:
this are the dependencies that im using:

[dependencies]
serde = { version = "1.0.117", features = ["derive"] }
serde-xml-rs = "0.4.0"

Thanks for the help in advance.
Regards

What serde xml crate have you tried? The serde is an abstraction between data types and data format and the actual mapping between the format and the data model is defined by each format crate.

Hi thanks for you question, im using serde-xml-rs

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.