XML output from MySQL

后端 未结 2 1183
遇见更好的自我
遇见更好的自我 2020-12-06 18:10

is there any chance of getting the output from a MySQL query directly to XML?

Im referring to something like MSSQL has with SQL-XML plugin, for example

2条回答
  •  感动是毒
    2020-12-06 18:38

    Using XML with MySQL seems to be a good place to start with various different ways to get from MySQL query to XML.

    From the article:

       use strict;
       use DBI;
       use XML::Generator::DBI;
       use XML::Handler::YAWriter;
    
       my $dbh = DBI->connect ("DBI:mysql:test",
                               "testuser", "testpass",
                               { RaiseError => 1, PrintError => 0});
       my $out = XML::Handler::YAWriter->new (AsFile => "-");
       my $gen = XML::Generator::DBI->new (
                                       Handler => $out,
                                       dbh => $dbh
                                   );
       $gen->execute ("SELECT name, category FROM animal");
       $dbh->disconnect ();
    

提交回复
热议问题