A simple class:
public class AddressDetails
{
public string DbServerName { get; set; }
}
So I just created a list of two object of it:
List<AddressDetails> AdrsList = new List<AddressDetails>();
AddressDetails detail1 = new AddressDetails();
detail1.DbServerName = "2k8";
AdrsList.Add(detail1);
AddressDetails detail2 = new AddressDetails();
detail2.DbServerName = "2k8R2D3";
AdrsList.Add(detail2);
Serialize(AdrsList);
And wanted to serialize it, with my method below:
public void Serialize(List<AddressDetails> details)
{
XmlSerializer serializer = new XmlSerializer(typeof(AddressList));
using (TextWriter writer = new StreamWriter(@"C:\TEMP\MyXML.xml"))
{
serializer.Serialize(writer, details);
}
}
The XML that it generates its element has the word "ArrayOf" in it, why? I don't want it, where is it coming from and how to fix it?
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfAddressDetails xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AddressDetails>
<DbServerName>2k8</DbServerName>
</AddressDetails>
<AddressDetails>
<DbServerName>2k8R2D3</DbServerName>
</AddressDetails>
</ArrayOfAddressDetails>