Child XElement Index

Given XElement, is there a way to find out this index of an element in the parent container?

I know what should be, but I just can't figure it out!

Thank!

+5
source share
3 answers

Try e.ElementsBeforeSelf().Count()

+9
source

Try using .ToList().IndexOf()one that returns the index of the object you are going to. Example:

var index = document.Elements().ToList().IndexOf(element);
+1
source

In vb

Dim Index As String = i.ToString.IndexOf(i.ToString)
0
source

All Articles