DBD::AnyData uses XML::Twig to create and query XML data sources but it doesn't handle all forms of nested tags so may or may not be of use to you.
But from the sound of what you've said, what you need is a templating system more than an XML querying system. Here's an example that produces output in the same format as your submission from multiple rows returned from a database query. The script is fully functional except for the missing DBI connection params.
#!perl -w
use strict;
use DBI;
use HTML::Template;
my $query = <<'';
SELECT tID,tBID,name
FROM taxon
WHERE sessionID=1 AND name<>'baz'
my $template = <<'';
<submission><tmpl_loop results>
<taxa tBID="<tmpl_var tBID>">
<taxon tID="<tmpl_var tID>">
<name><tmpl_var name></name>
</taxon>
</taxa></tmpl_loop>
</submission>
my $dbh = DBI->connect( ... );
my $results = $dbh->selectall_arrayref($query,{Slice=>{}});
my $tmpl = HTML::Template->new
( scalarref => \$template
, die_on_bad_params => 0
);
$tmpl->param( results => $results );
print $tmpl->output;
__END__
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.