Your current classes are serialized as shown below:
<?xml version="1.0" encoding="utf-16"?> <Configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Configs> <test> <string>gabc</string> <string>def</string> </test> </Configs> </Configuration>
I created this with the code:
Configuration obj = new Configuration { Configs = new tester { test = new string[] { "gabc", "def" } } }; XmlSerializer serializer = new XmlSerializer(typeof(Configuration)); string output; using (StringWriter writer = new StringWriter()) { serializer.Serialize(writer, obj); output = writer.ToString(); }
Use this code to change the class so that it is serialized the way you want to deserialize it. Serialization works in two ways.
You can implement the IXmlSerializable interface or use a range of xml attributes.
source share