using System;
using System.Xml;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.IO;
public class Test
{
public static void Main()
{
var xml = @"
<Contracts>
<Contract EntryType=""U"" ID=""401"" GroupCode=""1"">
</Contract>
</Contracts>
";
//Create our own namespaces for the output
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
//Add an empty namespace and empty value
ns.Add("", "");
var sr = new StringReader(xml);
var xr = new XmlTextReader(sr);
var ser = new XmlSerializer(typeof(ContractPosting));
var result = (ContractPosting)ser.Deserialize(xr);
foreach(var contract in result.Contracts)
Console.WriteLine("(" + contract.EntryType + ", " +
contract.ID + ", " + contract.GroupCode + ")");
}
}
// Define other methods and classes here
[XmlRoot("Contracts")]
public class ContractPosting {
[XmlElement("Contract", typeof(Contract))]
public List<Contract> Contracts { get; set; }
}
public class Contract {
[XmlAttribute("EntryType")]
public string EntryType { get; set; }
[XmlAttribute("ID")]
public int ID { get; set; }
[XmlAttribute("GroupCode")]
public int GroupCode { get; set; }
}