XML Deserialization |
| Stanley Tweedle posted at 09-May-08 03:57 |
How do I deserialize the following XML:
<InvestmentHolding InvestmentAccount="4015445" BookValue="+0000000000"> <InvestmentTransaction InvestmentAccount="4015445" IncreaseDecrease="I"/> <InvestmentTransaction InvestmentAccount="4015445" IncreaseDecrease="I"/> <InvestmentTransaction InvestmentAccount="4015445" IncreaseDecrease="D"/> <InvestmentTransaction InvestmentAccount="4015445" IncreaseDecrease="D"/> <InvestmentTransaction InvestmentAccount="4015445" IncreaseDecrease="D"/> </InvestmentHolding>
...into the InvestmentHolding object specified by the InvestmentHolding class below:
[XmlType("InvestmentHolding")] public class InvestmentHolding { private string investmentAccount; private string bookValue; private IList<InvestmentTransaction> investmentTransactions;
[XmlAttribute("InvestmentAccount")] public string InvestmentAccount { get { return investmentAccount; } set { investmentAccount = value; } } [XmlAttribute("BookValue")] public string BookValue { get { return bookValue; } set { bookValue = value; } } public IList<InvestmentTransaction> InvestmentTransactions { get { return investmentTransactions; } set { investmentTransactions = value; } } }
[XmlType("InvestmentTransaction")] public class InvestmentTransaction { private string investmentAccount; private string increaseDecrease;
[XmlAttribute("InvestmentAccount")] public string InvestmentAccount { get { return investmentAccount; } set { investmentAccount = value; } } [XmlAttribute("IncreaseDecrease")] public string IncreaseDecrease { get { return increaseDecrease; } set { increaseDecrease = value; } } }
|
|