XmlSerializer and XmlElement Fields

I have an xml that looks like this:

<Config> <A></A> <Template><B/><C/></Template> </Config> 

and I would like to deserialize it to get the <Template><B/><C/></Template> bit as an XmlElement or XmlNode. But when I try like this:

 public class Config { public string A; public XmlElement Template; } 

The template is set to <B/> . Any ideas?

+4
source share
1 answer

Decorate your template member with the XmlAnyElement attribute. That should do the trick.

+6
source

All Articles