I am copying data from "legacy" components over to "new" components. For the meta data it should be a simple xml copy (replacing the namespace) i.e.
newComponent.Metadata = oldComponent.MetaData.Replace("oldnamespace", "newnamespace");
However, over the years the order of the meta data fields has changed. If the fields are not in the exact order specified in the schema I get an error telling me the field that is not in the correct order is an invalid child element
.
For example, in the schema the order would be
<ExampleComponent ...>
<Field1></Field1>
<Field2></Field2>
</ExampleComponent>
But if I try add a component with the fields in a different order
<ExampleComponent ...>
<Field2></Field2>
<Field1></Field1>
</ExampleComponent>
... I get the error.
Why does the order matter? Is there a setting where I can tell Tridion to let me add elements in whatever order I like?