in reply to help to preserve the order of hash

You're tying %xhash, a hash unrelated to XML::Simple or what it returns. You would need to tie the multiple hashes XML::Simple creates, and you would have to do so before it populates them. This would involve changing XML::Simple*, and it would create a significant performance hit.

Of course, the better answer is to not use a hash in the first place. See ForceArray, or use a better parser.

* — almut showed a way of doing this non-obtrusively.