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:

        <name type="string">Pedro</name>
        <age type="number">37</age>
        <name type="string">Alex</name>
        <age type="number">30</age>

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")]
    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.

this are the dependencies that im using:

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

Thanks for the help in advance.

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.