1
我试图将此查询的结果绑定到组合框。C#xml linq查询结果格式化
public IEnumerable<object> getGenres()
{
var genres = (from item in data.Descendants("genre")
select new
{
Genre = item.Value
}).Distinct();
return genres.ToArray();
}
我的xml看起来像这样减去根元素。
<preformance>
<venue> Captain Cook Tavern </venue>
<date> 30/05/2013 </date>
<time> 11:00pm </time>
<band>
<name> Cult Disney </name>
<genre> Punk Rock</genre>
</band>
</preformance>
它以这种格式进行绑定。
{ Genre = Punk Rock }
对我来说,它看起来像我需要深入一个节点来获取实际值而不是xml标记本身,但我不知道该怎么做。
请问谁能指出我正确的方向?
谢谢
我明白我现在在做什么,谢谢。 – user3606900