I have this snippet of XML and I'm attempting to Deserialize it. I have tried the following class to deserialize to but I dont get the address lines I only get the city state and postal code. Can someone point out my mistake? I can't see what I'm doing wrong. XML and class are just below.
XML:
<RemitTo>
<Address>
<AddressLine lineNumber="1">Blah blah</AddressLine>
<AddressLine lineNumber="2">bah bah bah</AddressLine>
<AddressLine lineNumber="3">bah3</AddressLine>
<City>Minneapolis</City>
<State>MN</State>
<PostalCode>55413</PostalCode>
<Country isoCountryCode="US">United States</Country>
</Address>
</RemitTo>
CLASS:
[XmlRoot("RemitTo")]
public partial class RemitTo
{
[XmlElementAttribute("Address")]
public List<Address> RemitToAddress { get; set; }
}
public partial class Address
{
[XmlArray("Address")]
[XmlArrayItem("AddressLine")]
public List<string> AddressLine { get; set; }
public string City { get; set; }
public string State { get; set; }
public string PostalCode { get; set; }
public string Country { get; set; }
}
In code im doing this.
RemitTo i;
XmlSerializer serializer = new XmlSerializer(typeof(RemitTo));
i = (RemitTo)serializer.Deserialize(addressReader);
No comments:
Post a Comment