Extensions.InDocumentOrder(T) returns a collection of nodes that contains all nodes in the source collection
Imports System
Imports System.Xml
Imports System.Xml.XPath
Public Class MainClass
Public Shared Sub Main()
Dim xmlTree As XElement = _
<Root>
<Item>
<aaa>1</aaa>
<bbb>2</bbb>
</Item>
<Item>
<ccc>3</ccc>
<aaa>4</aaa>
</Item>
<Item>
<ddd>5</ddd>
<eee>6</eee>
</Item>
</Root>
Dim elementList() As XElement = _
{ _
xmlTree...<ddd>(0), _
xmlTree...<ccc>(0), _
xmlTree...<aaa>(0) _
}
Dim inDocOrder = elementList.InDocumentOrder
For Each el As XElement In inDocOrder
Console.WriteLine(el)
Next
End Sub
End Class