quick-xml icon indicating copy to clipboard operation
quick-xml copied to clipboard

deserialize_struct loses the main element

Open gkorland opened this issue 3 years ago • 3 comments

I'm using quick-xml to deserialize to another generic structure, but it seems like the main element is not passed to the visitor. e.g.

<a><b>1</b></a>

when deserialize and serialized returned as:

"<b>1</b>"

Looking at the code it seems like the issues is since in https://github.com/tafia/quick-xml/blob/ad57bc29e8d9b10309748ce362fffc3580322cf5/src/de/mod.rs#L727 name is never passed to the visitor and only the internal map is.

gkorland avatar Jul 31 '22 12:07 gkorland

What struct you are using to represent that XML?

Note, that name of any type are never used in the XML representation. Only names of fields / enum variants has a meaning. One exception -- you could use the type name as a root tag name during serialization, but this is only for convenience. Usually you should specify your root tag manually

Mingun avatar Jul 31 '22 12:07 Mingun

I'm trying to create an agnostic storage that can consume XML/JSON/BSON and return the data back to the user according to their need.

gkorland avatar Aug 01 '22 07:08 gkorland

slightly off topic: could someone edit the title of this issue to replace loose with the correct word lose.

Title should be "deserialize_struct loses the main element"

spazm avatar Feb 20 '23 09:02 spazm