It looks like XML::Simple loses the distinction between attributes and child elements, when building the returned data structure. How do you preserve the actual content when writing it back out?
This is definitely one of the difficulties I've had with XML::Simple. XMLin and XMLout aren't the inverse of each other. In other words, it's difficult write out the same thing that you read in and vice versa.
I if you need that, you should probably look at XML::Twig.