Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

XML::Generator::DBI Tutorial

by jeffa (Bishop)
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?
[marto]: which is a shame, I had a really productive day yesterday
[Corion]: marto: Meh, so it'll be a day of cleaning out email...
[marto]: and hoped that I'd be able to continue the momentum :)
[marto]: I can't even access client email, nor my employers since those idiots moved to citrix
[marto]: it literally doesn't work. Also, via their citrix interface theres no way to open attachments, or upload an attachment for sending. The company policy is that you email you work account from a personal one, and forward it on from there :/

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2018-01-16 08:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (175 votes). Check out past polls.

    Notices?