Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

XML::Generator::DBI Tutorial

by jeffa (Chancellor)
on Jul 12, 2002 at 03:52 UTC ( #181206=perltutorial: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use strict;
    use DBI;
    use XML::Generator::DBI;
    use XML::Handler::YAWriter;
    
  2. or download this
    my $dbh = DBI->connect(
       qw(DBI:vendor:database:host user pass),
       {RaiseError=>1},
    );
    
  3. or download this
    my $handler = XML::Handler::YAWriter->new(AsFile => 'foo.xml');
    
  4. or download this
    my $generator = XML::Generator::DBI->new(
       Handler => $handler,
       dbh     => $dbh,
       Indent  => 1,
    );
    
  5. or download this
    $generator->execute('select bar,baz from foo');
    
  6. or download this
    use strict;
    use DBI;
    use XML::Generator::DBI;
    use XML::XPath;
    use XML::XPath::Builder;
    
  7. or download this
    my $dbh = DBI->connect(
       qw(DBI:vendor:database:host user pass),
       {RaiseError=>1},
    );
    
  8. or download this
    my $handler = XML::XPath::Builder->new();
    
  9. or download this
    my $generator = XML::Generator::DBI->new(
       Handler => $handler,
       dbh     => $dbh,
    );
    
  10. or download this
    my $xp = $generator->execute('select bar,baz from foo');
    
  11. or download this
    my $nodeset = $xp->find('/database/select/row/bar');
    
    print $_->string_value, "\n" for $nodeset->get_nodelist;
    
  12. or download this
    use strict;
    use DBI;
    ...
       qw(DBI:vendor:database:host user pass),
       {RaiseError=>1},
    );
    
  13. or download this
    my $handler = XML::Handler::HTMLWriter->new();
    
  14. or download this
    my $filter = XML::Filter::SAX1toSAX2->new(Handler => $handler);
    
  15. or download this
    my $generator = XML::Generator::DBI->new(
       Handler      => $filter,
    ...
    );
    
    $generator->execute('select foo as td,bar as td from baz');
    
  16. or download this
    use strict;
    use DBI;
    ...
       qw(DBI:vendor:database:host user pass),
       {RaiseError=>1},
    );
    
  17. or download this
    my $writer    = XML::SAX::Writer->new();
    my $xsl_filt  = XML::Filter::XSLT->new(Handler => $writer);
    ...
       Handler => $sax_filt,
       dbh     => $dbh,
    );
    
  18. or download this
    $xsl_filt->set_stylesheet_uri('foo.xsl');
    
    $generator->execute('select bar,baz from foo');
    
  19. or download this
    use strict;
    
    ...
    use XML::Generator::DBI;
    use XML::Filter::SAX1toSAX2;
    use XML::Filter::XSLT;
    
  20. or download this
    my $style = 'dynamic.xsl';
    my %field = (
    ...
       title => 'song.title as Song',
       year  => 'album.year as Year',
    );
    
  21. or download this
    print header, start_html, start_form,
       checkbox_group(
    ...
       ),
       submit('go'), end_form,
    ;
    
  22. or download this
    if (param('go')) {
    
  23. or download this
       my @ok = map { $field{$_} } grep $field{$_}, param('fields');
    
  24. or download this
       die 'no valid fields selected' unless @ok;
       my $select = join(',', @ok);
    
  25. or download this
       my $dbh = DBI->connect(
          qw(DBI:vendor:mp3:host user pass),
          {RaiseError=>1},
       );
    
  26. or download this
       my $writer    = XML::SAX::Writer->new();
       my $xsl_filt  = XML::Filter::XSLT->new(Handler => $writer);
    ...
          dbh         => $dbh,
          ShowColumns => 1,
       );
    
  27. or download this
       die "could not open file $style" unless -r $style;
    
       $xsl_filt->set_stylesheet_uri($style);
    
  28. or download this
       $generator->execute("
          select $select
    ...
          order by artist.name,album.year,album.title
       ");
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://181206]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2015-07-05 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls