以下は私のXMLファイルです。
<Employee>
<FirstName>#{FirstName}#</FirstName>
<LastName>#{LastName}#</LastName>
<DOB>#{DOB}#</DOB>
<Address>#{Address}#</Address>
<Transcation>
<Month>#{Month}#</Month>
<Amount>#{Amount}#</Amount>
</Transcation>
<Transcation>
<Month>#{Month}#</Month>
<Amount>#{Amount}#</Amount>
</Transcation>
<Transcation>
<Month>#{Month}#</Month>
<Amount>#{Amount}#</Amount>
</Transcation>
<Transcation>
<Month>#{Month}#</Month>
<Amount>#{Amount}#</Amount>
</Transcation>
そして私のシリアル化可能なクラスは
[XmlRoot("Employee"), Serializable]
public class Employee
{
[XmlAnyElement]
public List<XmlElement> EmployeeDetails { get; set; }
}
しかし、私はこのようなものを手に入れたい
EmployeeDetailsでは、FirstName、LastName、DOB、Address、....のみをシリアル化する必要があります。また、シリアル化可能な要素としてMonthとAmountを含む別のクラスでTranscationのリストを取得する必要があります。
このようなもの
[XmlRoot("Employee"), Serializable]
public class Employee
{
[XmlAnyElement]
public List<XmlElement> EmployeeDetails { get; set; }
[XmlElement("Transcation")]
public List<Transcation> Transcations { get; set; }
}
public class Transcation
{
[XmlElement("Month")]
public string Month{ get; set; }
[XmlElement("Amount")]
public string Amount{ get; set; }
}
これどうやってするの ?