Also, particularly in this case, consider all of the technological alternatives that you have to do this very-common task, which is: transforming one XML document into another XML document. There are existing technologies called XSLT and XQuery which are specifically designed to do this ... without writing a computer-program in any language to do it.
Before you do much of anything else on this project, Google terms such as saxon, xalan, libxslt, and MSXML. Of course Perl has support for it, too, e.g. in XML::LibXSLT, but it may well be that to do this task you can ... well, maybe you ca do it in your web-browser, word processor, or spreadsheet!