Я делаю следующий запрос на XDocument
. Последний уровень .Descendants("Instance")
дает список XElements вида:Разбор XDocument с использованием LINQ
<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.Value)'? –