I had task to check if XML nodes are in correct order. After some research basically all I needed was this line:
var nodes = myXml.Elements().ToList();
So, code would look something like this:
var nodes = myXml.Elements().ToList(); var expectedOrder = new[] { "first", "second", "third", "fourth" }.ToList(); var actualOrder = nodes.Select(node => node.Name.LocalName).ToList(); Assert.AreEqual(string.Join(",", expectedOrder), string.Join(",", actualOrder));