Your Link:
https%3A%2F%2Fstackoverflow.com%2Fquestions%2F3915262%2Fget-the-sub-index-in-foreach-loop-in-simplexmlelement