Skip to content

serde deserialize, attribute and child element share the same name #293

Closed
@ghost

Description

i have a funny problem parsing COLLADA xml documents:

<skin source="#Cylinder_002-mesh">
        <source id="Armature_JointBase_001-skin-joints"> .. </source>
</skin>

And i is not clear how the Rust code has to look to parse something like this.

My naive approach was something like this:

#[derive(Deserialize)]
pub struct Skin {
    #[serde(rename = "source")]
    pub sources: Vec<SkinSource>,
}

#[derive(Deserialize)]
pub enum SkinSource {
    Source{id: String},
    Attr(String),
}

But this did not work.

Metadata

Metadata

Assignees

Labels

enhancementserdeIssues related to mapping from Rust types to XML

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions