From: Date: April 24 2005 9:39pm Subject: RE: MYSQL to XML List-Archive: http://lists.mysql.com/mysql/183030 Message-Id: <001601c54905$4c29d040$0100a8c0@redfox> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi Mikel, There are a lot of possibilities including commercial (:o)) products. I suggest you those solutions. The output should be reparsed for your needs : 1. the -X on client : C:\Mysql>mysql -u mathias world -X -e "desc country" Code char(3) PRI Name char(52) Continent ... ... 2. install perl DBI and DBIx-XML_RDB modules : #!perl -w # --------------------------------------------------------------- # Describe2xml # Author : Mathias FATENE # Date : 24 april 2005 # --------------------------------------------------------------- use DBIx::XML_RDB; my $userid='root'; my $password='**************'; my $dbname='world'; my $dsn = "DBI:mysql:database=$dbname;host=localhost"; my $xmlout = DBIx::XML_RDB->new($dsn,'mysql',$userid, $password) || die "Failed to make new xmlout"; $xmlout->DoSql("describe country"); print $xmlout->GetData; C:\Mysql>perl describe.pl Code char(3) PRI Name char(52) ... ... 3. install Perl DBI and DBD-Mysql and use my program (formatted for your needs) : #!perl -w # --------------------------------------------------------------- # Describe2xml # Author : Mathias FATENE # Date : April, 24 2005 # --------------------------------------------------------------- use DBI; my $userid='root'; my $password='************'; my $dbname='world'; my $dsn = "DBI:mysql:database=$dbname;host=localhost"; my $dbh = DBI->connect($dsn,$userid, $password,{'RaiseError' => 1}); # --------------------------------------------------------------- # describe country table and print it in XML format # --------------------------------------------------------------- my $table="country"; $sth = $dbh->prepare("describe $table"); $sth->execute(); print "\\n"; while (my @ref = $sth->fetchrow_array()) { print "\\n"; } $sth->finish(); print "\\n"; # Disconnect from the database. $dbh->disconnect(); C:\Mysql>perl desc.pl country
is this beautifull ? I will modify Describe2xml.pl to be more parametrized (user, db, pass, FK, ...) as soon as possible. Mathias >> Hi list, does it possible for MySQL to generate XML in the followin format: >> >> >> > required="true" type="VARCHAR" size="10"/> >> >> >> >> >> >> >> >> >>
>> >> This XML is the structure of the ServiceType table, I'll hope that you >> can >> help me >> >> Thnx in advanced >> >> Greetings >> >> P.S. Any suggestions (tools) will be appreciated >> >> >> >> Thread >> >> * MySQL to XML - Mikel -, April 23 2005 1:07am >>