I create an IEnumerable object that just contains the nodes I want from an xml file:
IEnumerable<XElement> rosters = XDocument.Load("roster.xml")
.Elements("rosterlist")
.Elements("roster")
.Where(w => w.Element("division")
.Value
.Equals("SUPER AWESOME DIVISION"));
So it's a collection of these:
<rosterlist>
<roster>
<userid>1</userid>
<name></name>
<etc></etc>
</roster>
<roster>
<userid>2</userid>
<name></name>
<etc></etc>
</roster>
</rosterlist>
I want to grab only the users where the userid
attribute is also a userid
node within the rosters
collection.
IEnumerable<XElement> users = XDocument.Load("user.xml")
.Elements("userlist")
.Elements("user")
.Where(w => rosters.Elements("userid")
.Contains(w.Attribute("userid").Value));
But it is giving me an error:
The type arguments for method 'System.Linq.Enumerable.Contains(System.Collections.Generic.IEnumerable, TSource)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
What is wrong with my approach?