ImJeremyHe / xmlserde

A user-friendly Rust library for serializing or deserializing the XML files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting <> (empty tag) while serializing a struct with ty = "untag"

vastvik123 opened this issue · comments

#[derive(XmlSerialize)]
#[xmlserde(root = b"root")]
struct Wrapper<T:XmlSerialize> {
  #[xmlserde(name = b"header", ty = "attr")]
  header: String,
  #[xmlserde(ty = "untag")]
  body: T,
}

#[derive(XmlSerialize)]
#[xmlserde(root = b"Foo")]
struct Foo {
  #[xmlserde(name = b"Bar", ty = "child")]
  bar: Bar 
}

when serializing, Wrapper, Im expecting this,
<root header=""> <bar> </bar> <root>
But, Im getting this xml, which has empty tags
<root header=""> <> <bar> </bar> </> </root>

Anyway to achieve this, without writing custom implementation for serialize trait?

@vastvik123 Thanks for your feedback.
#[xmlserde(root=b"")] is only for the the outest element.
We use #[xmlserde(name="x")] to tell the program which tag should be looking for in the fields, and we need a similar mechanism to tell what the program the outest tag is. That's why we need the root attribute.
Can you remove the #[xmlserde(root = b"Foo")] and have an other try?

Hey @ImJeremyHe Thanks for quick response.
I tried again after removing #[xmlserde(root = b"Foo")] but still getting the same xml with empty tags <>

This is my Cargo.toml. Im using 0.8.0 version
[dependencies]
xmlserde = "0.8.0"
xmlserde_derives = "0.8.0"

Then this is a bug. I will check and fix it later on