I am trying to deserialize an object of credit card bins for brand validation on a form, but can't get it done properly. Either the inside object doesn't deserialize, or the main list of brands comes null. Can anyone give me a hand or two?
My XML is like this:
<?xml version="1.0" encoding="utf-8"?>
<Brands>
<Brand type="visa">
<Bins>
<Bin enabled="true" value="123" />
<Bin enabled="true" value="456" />
<Bin enabled="true" value="789" />
</Bins>
</Brand>
<Brand type="master">
<Bins>
<Bin enabled="true" value="987" />
<Bin enabled="true" value="654" />
<Bin enabled="true" value="321" />
</Bins>
</Brand>
</Brands>
and my latest code(which brings brandsCollection null) is:
[XmlRoot("Brands")]
public class CreditCardBrand
{
[XmlArray("Brands"), XmlArrayItem("Brand")]
public CreditCardBrandCollection[] brandsCollection { get; set; }
}
public class CreditCardBrandCollection
{
[XmlElement("Bins")]
public CreditCardBrandBins[] binsCollection { get; set; }
[XmlAttribute("type")]
public CreditCardBrands brand { get; set; }
}
public class CreditCardBrandBins
{
[XmlAttribute("value")]
public string bin { get; set; }
[XmlAttribute("enabled")]
public bool enabled { get; set; }
}
I want to deserialize this xml into an array of Brands, each brand having a property name(type) and an array of bins(only the enabled ones) associated to them, so I can put it in memory at my system on startup.