Check out DBIx-XML_RDB. Specifically
designed to do what you're asking, I believe.
From the synopsis:
use DBIx::XML_RDB;
my $xmlout = DBIx::XML_RDB->new($datasource,
"ODBC", $userid, $password, $dbname) ||
die "Failed to make new xmlout";
$xmlout->DoSql("select * from MyTable");
print $xmlout->GetData;