XML にシリアライズしたい次のクラス構造があります。
public class Foo
{
[XmlArray("approxPriceList")]
[XmlArrayItem("approxPrice")]
public List<ApproxPriceElement> ApproxPriceList { get; set; }
}
public class ApproxPriceElement
{
[XmlAttribute("currency")]
public string Currency { get; set; }
[XmlElement("approxPrice")]
public decimal? ApproxPrice { get; set; }
}
をシリアル化Fooすると、次の XML が得られます。
<approxPriceList>
<approxPrice currency="aud">
<approxPrice>2220.00</approxPrice>
</approxPrice>
</approxPriceList>
私が欲しいのは次のとおりです。
<approxPriceList>
<approxPrice currency="aud">2220.00</approxPrice>
</approxPriceList>
に変更ApproxPriceListするFooことも考えられましたが、属性をリスト内のそれぞれにList<decimal?>関連付ける方法がわかりません。currencyapproxPrice
これを達成する方法はありますか?