Any() linq query on XmlNodeList

I am not able to use Any() on XmlNodeList. I have also used System.Linq and System.Xml.Linq namespaces as well. But still I'm not finding any such extension methods on XmlNodeList.

How I can use it??

Jon Skeet
people
quotationmark

The problem is that XmlNodeList only implements IEnumerable, not IEnumerable<T>. The simplest way to use LINQ on it is to call Cast:

var query = nodeList.Cast<XmlNode>()
                    .Where(...)
                    ...;

Alternatively, ditch the old XML API and use LINQ to XML, which is a much nicer API in general and supports LINQ really nicely :)

people

See more on this question at Stackoverflow