【发布时间】:2012-03-06 10:14:27
【问题描述】:
我正在对XDocument 进行以下查询。最后一级.Descendants("Instance") 产生一个 XElement 列表,其形式如下:
<Instance>filepath1</Instance>
<Instance>filepath2</Instance>
<Instance>filepath3</Instance>
<Instance>filepath4</Instance>
查询
List<string> fileNames = xDoc.Descendants("Main")
.FirstOrDefault()
.Descendants("SecondLevel")
.FirstOrDefault()
.Descendants("Instance")
.Select().ToList(); //this line is not correct. Need to get the instances node values as List<string>
如何将值filepath1、filepath2.. 存储在List<string> 中?
【问题讨论】:
-
类似
Select(x=>x.Value)?