I'm merging a couple of .xml files together, and need to take certain child elements from each .xml document and put them into a 3rd. And that's OK, but the problem is that then my "child" nodes are in a somewhat random order (well, what I picked from the first file, followed by what I picked from the 2nd), and the schema file (the .xsd) defines these children as a "sequence" or xs:sequence
if you prefer. So the output file then doesn't pass validation anymore because while each file had its elements in order, the resulting file does not.
What I'm wondering, is that since I have the .xsd, and I have a "mostly" valid .xml file, is there any way in C# to "move" all the nodes into the correct order according to the order defined in the .xsd without a lot of pain? Obviously I could implement a kind of "sort" but I'm hoping there's something built-in. Or better yet, a built-in merge that does this automatically could also work.
Any ideas?