http://www.perlmonks.org?node_id=7594

btrott has asked for the wisdom of the Perl Monks concerning the following question: (database programming)

How do I dump a database table into XML format?

Originally posted as a Categorized Question.

  • Comment on How do I dump a database table into XML format?

Replies are listed 'Best First'.
Re: How do I dump a database table into XML format?
by btrott (Parson) on Apr 14, 2000 at 07:56 UTC
    There's a module on CPAN designed exactly for this: DBIx::XML_RDB. You give it a SQL statement, and it executes the statement and dumps the returned rows and columns out in XML:
    use DBIx::XML_RDB; my $xmlout = DBIx::XML_RDB->new($datasource, "ODBC", $userid, $password, $dbname) or die "Failed to make new xmlout"; # tell DBIx::XML_RDB which data it should retrieve # (by using a SELECT statement) $xmlout->DoSql("select id, name from foo"); # write out the data in XML format print $xmlout->GetData;
    The module installs two utility scripts: sql2xml dumps SQL rows into XML, and xml2sql does the opposite.
Re: How do I dump a database table into XML format?
by silent11 (Vicar) on Jun 19, 2002 at 02:09 UTC
    If you are using MySQL try this from the command line.
    mysqldump --xml database_name table_name > out_file.xml
    -Silent11