You could try using
XML::Writer. This works just fine if you are doing a conversion of some data (e.g. from a text file) into XML and all that you are really after is help with the formatting, escaping etc.
As mentioned in the previous posts, an example of the data that you are trying to convert would help us to help you!
inman