Split IEnumerable<XElement> into separate lists by Attribute Value
I have a variable set of XEelements (IEnumerable<XElement>) like so:
I don't know the number of elements, number of unique ids or any of the Attribute values in advance. I want to split this IEnumerable into x number of collections (can be list or ienumerable) by the
id
Attribute. In this example, I would get two collections, split by the ids 2892 and 2646.
What's the tidyest way to achieve this? I'm guessing it's via Linq, but cannot figure for the life of me how...2 Replies
You nailed it - thanks dude