I've been having some trouble writing queries in LINQ to grab the data i need from an XML file.
The XML file set up looks like this
<Study id ="">
<Multi>
<filepath id =""></filepath>
<filepath id ="display"></filepath>
<combined></combined>
</Multi>
</Study>
<Study id ="">
<Multi>
<filepath id =""></filepath>
<filepath id ="display"></filepath>
<combined></combined>
</Multi>
</Study>
I'm trying to get the value of the filepath node where id ="display"
var displaySettingsQuery = (from n in _XML.Descendants("Study").Descendants("Multi")
where n.Element("Multi").Attribute("id").Value == "display"
select n.Element("filepath").Value);
This doesn't seem to work because the Element() method only grabs the first instance of "Multi". However if I use Elements(), I get a syntax error, since Elements is a Ienumerable, so I can't call attribute directly. How would I go about iterating through the "Multi" collection in order to do my comparison?
Thanks for the assistance.