serde-xml-rs icon indicating copy to clipboard operation
serde-xml-rs copied to clipboard

duplicate field `$value`'

Open codingatc opened this issue 2 years ago • 1 comments

I am processing the following file. https://github.com/KhronosGroup/OpenGL-Registry/blob/main/xml/gl.xml

It has lines such as this:

            <proto><ptype>GLVULKANPROCNV</ptype> <name>glGetVkProcAddrNV</name></proto>
            <proto>void <name>glWaitVkSemaphoreNV</name></proto>

So I would like to sometimes extract the string under proto, or the ptype, but always get the name, as it is always present. However:

#[derive(Debug, Deserialize, PartialEq)]
struct Proto {
    #[serde(rename = "$value")]
    return_type: String,
    ptype: Option<String>,
    name: String,
}

Doesn't work. Is there a way to state that return_type should only have the non-fields of the xml member proto?

codingatc avatar Mar 22 '23 21:03 codingatc

This crate doesn't currently support mixed content text and elements.

punkstarman avatar Apr 13 '25 13:04 punkstarman