Reputation: 25828
Given an XElement
is there a way to find out that element's index within the parent container?
I know there must be but I just can't figure it out!
Thanks!
Upvotes: 7
Views: 5476
Reputation: 1840
Try using .ToList().IndexOf()
which returns the index of the object you pass in. Example:
var index = document.Elements().ToList().IndexOf(element);
Upvotes: 1