Category: XML
Author/Contact Info Anton van der Steen anton.vandersteen@chello.nl Eindhoven/The Netherlands/Europe
Description: With this piece of code you can extract data from a table within MySQL and put in a XML document. The perl packages I use in this listing are standard packages, which can be found at ActiveState.com and be installed with ppm. Have fun.
#!perl/bin/perl

use strict;
use DBIx::XML_RDB;
my $dsn = "DBI:mysql:database=test;host=localhost";

my $dbx = DBIx::XML_RDB->new($dsn, 'mysql', 'root', 'admin');
$dbx->DoSql(qq{ SELECT * from table });

open(XML, ">table.xml") or
            die "Could not open file for writing: $! \n";

print XML $dbx->GetData;

close XML or die "Error closing file: $!\n";
Replies are listed 'Best First'.
Re: XML Output from MySQL
by jeffa (Bishop) on Apr 17, 2006 at 19:45 UTC