How can I find the order of nodes in an XML document?
What I have is a document like this:
The answer by erikkallen is absolutely correct.
However, if the original document/schema may be modified, an alternative is to store the position/index in an attribute. I use a mix of both approaches, depending who the "originator" of the XML is and the type of queries that need to be performed upon it. At the end of the day I rue most use of XML except possibly "dumb storage" in SQL Server and am usually happy when I can dump it (XML) for normalized tables.
Happy dealing with the unmentioned limitations of "enterprise-grade" products -- the wonders never end.