Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple descendants types linq

I sometimes do this:

XElement.Descendants("mynodename");

is there a way to do something like this"

XElement.Descendants("mynodename or myothernodename");
like image 322
zachary Avatar asked Jan 13 '10 19:01

zachary


1 Answers

Not in one method call - but you can use:

element.Descendants()
       .Where(x => x.Name.LocalName == "mynodename" 
                   || x.Name.LocalName == "myothernodename")
like image 94
Jon Skeet Avatar answered Oct 04 '22 00:10

Jon Skeet