Saturday, February 19, 2011

XmlSerializer and XmlElement fields

Hi,

I have an xml that looks like this:

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

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

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

the Template is set to <B/> only. Any ideas?

From stackoverflow
  • Decorate your Template member with an XmlAnyElement attribute. That should do the trick.

    Grzenio : Cheers, works like a dream!

0 comments:

Post a Comment