You can read your template file with XML::Simple, then add elements to the resulting data structure and, finally, create a new xml file from the combined contents, again with XML::Simple.
Comment on Re: how to include xml contents in another xml file