You could use CGI.pm for creating XML as it has nice feature that it will autogenerate HTML functions. Try this:
use CGI qw(:standard tag);
print tag({-type=>'invented', 'I made this up');
Which will print
<TAG TYPE="invented">I made this up</TAG>
... but is does have the disadvantage that it converts all tag names to upper case.
A quick check on CPAN also finds a module called XML::Generator which looks like it might do what you want.
How are you planning to deliver the XML to the browser? You should check out
AxKit.