This is not the purpose of the XML format. The parser must have the power to reorder the tags. Matlab's parser orders them alphabetically.
If you really want to conserve the order of tags, you treat the file as a text file, not as an XML object. Then the best idea it to omit the power of the XML format and perform simple text operations with the file. This hurts the idea of XML massively, but if it is your intention, do it.