I'm new to XML in .NET, but here goes.
The XmlSerializer doesn't know what to do with the ArrayList elements.
You can convert the the ArrayList to an array of objects and annotate that
array with attributes so that the XmlSerializer will know what to do.
There may be a more conise way of doing this, but I don't know what it is;
using System;
using System.Collections;
using System.Xml.Serialization;
namespace arraylist
{
public class DriversLicense
{
public string state;
public string number;
public DriversLicense() {
this.state = null;
this.number = null;
}
public DriversLicense( string state, string number ) {
this.state = state;
this.number = number;
}
}
public class SocialSecurityNumber
{
public string number;
public SocialSecurityNumber() {
number = null;
}
public SocialSecurityNumber( string number ) {
this.number = number;
}
}
public class Identification
{
[XmlElementAttribute("SocialSecurityNumber",
typeof(SocialSecurityNumber))]
[XmlElementAttribute("DriversLicense", typeof(DriversLicense))]
public object[] Items;
}
class Class1
{
[STAThread]
static void Main(string[] args)
{
ArrayList al = new ArrayList();
al.Add( new SocialSecurityNumber( "333-22-4444" ) );
al.Add( new DriversLicense( "NY", "1234567890" ) );
Identification ident = new Identification();
ident.Items = al.ToArray();
XmlSerializer ser = new XmlSerializer( typeof(Identification) );
ser.Serialize( Console.Out, ident );
Console.ReadLine();
}
}
}
> Hello all,
>
[quoted text clipped - 7 lines]
> Thanks,
> Chris