in reply to Converting a data structure to XML

Look at XML::Writer it is easy to use and can do what you want.
Boris