这个发生挺有意思的,有时候我们打乱文档元素原有的顺序,比方说对元素顺序进行倒转Reverse
但是有时候又需要取回原有的顺序,这个时候就可以使用InDocumentOrder,下面是例子
这里面已经对结点顺序进行了倒转
IEnumerable<XNode> nodes =
xDocument.Element("BookParticipants").Elements("BookParticipant").
Nodes().Reverse();
下面的输出可以看到InDocumentOrder所起的作用
Source node: <LastName>Buckingham</LastName>
Source node: <FirstName>Ewan</FirstName>
Source node: <LastName>Rattz</LastName>
Source node: <FirstName>Joe</FirstName>
Source node: <!--This is a new author.-->
Ordered node: <!--This is a new author.-->
Ordered node: <FirstName>Joe</FirstName>
Ordered node: <LastName>Rattz</LastName>
Ordered node: <FirstName>Ewan</FirstName>
Ordered node: <LastName>Buckingham</LastName>