use LINQ on XmlNodeList

Aside from the fact what your code snippet wouldn't be compiled because of non-unique node variable (first outside of linq query and second in "where" method lambda), you have also missed Attributes in your query.

It should be something like

var node = list.Cast<XmlNode>()
               .Where(n => n.Attributes["id"].InnerText == "abc")
               .Select(x => x.Attributes["abv"].InnerText);

The InnerText for a node is the text that appears between <node> and </node>. So for, eg <Y attributes /> there is no inner text.

You need to use node => node.Attributes["id"].Value == "abc"

Tags:

C#

.Net

Linq

Xml