我正在对一个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)
? - L.B