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!
Try e.ElementsBeforeSelf().Count()
Try using .ToList().IndexOf()
which returns the index of the object you pass in. Example:
var index = document.Elements().ToList().IndexOf(element);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With