我在XDocument
上执行以下查询。最后一级.Descendants("Instance")
产生形式的XElements的列表:使用LINQ解析XDocument
<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>
?
像'选择(X => x.Value)'? – 2012-03-06 10:19:44