Thanks for replying, Patrick.
When the .NET framework is serializing a class instance, the fields of the class seem to be outputted in random order. I took a look at the generated XmlSerializerWriter for the class and the code confirms the random order of class' fields in the XML output.
InfoPath refuses to load the serialized XML because it does not conform to the XML schema of the InfoPath template. The schema dictates a sequence of fields, validates the loading XML form against the schema and loading the XML fails. The fields in the (via XSD.exe generated) class have the exact order of the sequence, but a serialized instance shows fields in a different order. The order expected is the order of fields the schema dictates (and is also the order of the fields in the class generated by XSD.exe)
I think Microsoft tried to fix things in .NET 2.0 by adding an 'Order' field to the XML attributes in a generated class ("XSD.exe /order ..."), but an initial test showed me that .NET 2.0 XML serialize output shows again a random order of fields in the XML.
Back to your suggestion about importing in InfoPath. I'm not sure what you mean by that.
'TotalForm' is a pretty large form, combining data from severial other forms. Combining data is performed in C# code by first deserializing the source forms XML, creating a TotalForm class instance, filling fields and serializing the instance to XML.
'TotalForm' is an InfoPath template and the serialized XML for 'TotalForm' should conform to the template's schema in order for InfoPath to be able to load the XML. It's not a InfoPath bug, but a validation error by the schema.
XmlSerialization of the .NET framework however changes the field's order in de XML.
Perhaps I should abandon serialization of a TotalForm class instance and look for another way to create the TotalForm's XML....