I'm attempting to serialize a class to XML, but I have some strict requirements on the output (because I want Rails' ActiveResource to consume it). One of those requirements is specifically for arrays. Here's two examples:
class Person { public string FirstName { get; set; } }
List<Person> people = new List<Person>();
people.Add( new Person {...} );
people.Add( new Person {...} );
If I serialize the people list, I need this output:
<People type="array">
<Person>
<FirstName>blah</FirstName>
</Person>
<Person>...</Person>
</People>
Another example is like this:
class Person
{
public string FirstName { get; set; }
public List<Address> Addresses { get; set; }
}
class Address
{
public string Line1 { get; set; }
}
If a serialize a person, I need this output:
<Person>
<FirstName>blah</FirstName>
<Addresses type="array">
<Address>...</Address>
</Addresses>
</Person>
Is there anyway to trick the XmlSerializer into producing this output?