I need XML in the following format:
<configuration> <logging>...</logging> <credentials>...</credentials> <credentials>...</credentials> </configuration>
I am trying to create a Configuration class that has the [Serializable] attribute. For serializing credential nodes, I have the following:
[XmlArray("configuration")] [XmlArrayItem("credentials", typeof(CredentialsSection))] public List<CredentialsSection> Credentials { get; set; }
However, when I serialize this to XML, XML has the following format:
<configuration> <logging>...</logging> <configuration> <credentials>...</credentials> <credentials>...</credentials> </configuration> </configuration>
If I delete the line [XmlArray("configuration")] , I get the following:
<configuration> <logging>...</logging> <Credentials> <credentials>...</credentials> <credentials>...</credentials> </Credentials> </configuration>
How can I serialize this the way I want with multiple <credentials> nodes within the same root node <configuration> ? I wanted to do this without having to implement IXmlSerializable and do custom serialization. This is how my class is described:
[Serializable] [XmlRoot("configuration")] public class Configuration : IEquatable<Configuration>
c # xml serializable xml-serialization xml-deserialization
Sarah Vessels Jul 21 '10 at 19:44 2010-07-21 19:44
source share