私はこれに似たxml構造を持っています:
<cars>
<car>
<make>Ford</make>
<model>F-150</model>
<year>2011</year>
<customs>
<customAttribute>Color</customAttribute>
<customValue>Black</customValue>
<customAttribute>Doors</customAttribute>
<customValue>2</customValue>
</customs>
</car>
</cars>
そして、次のようなメソッドで車のリストを返したいと思います:
return (from car in cars.Descendants("car")
select new Car {
Make = car.Element("make").Value,
Model = car.Element("model").Value,
Year = car.Element("year").Value
Color = ?????,
Doors = ?????
});
Color フィールドと Doors フィールドに入力するにはどうすればよいですか? 適切な customValue ノードの customAttribute 値を取得する必要があります。
これを達成する方法がよくわかりません。
どうもありがとう!