in reply to Rolling in the sheets with XML

Ahhh, i see that working with the dreaded DOM has already got you thinking like a Java coder who has never been introduced to java.util.Hashtable. ;) What i mean is that you are not being generic enough. Check out this code which uses XML::Simple:
use strict; use warnings; use DBI; use XML::Simple; my $dbh = DBI->connect( ... ); my $xml = XMLin(\*DATA, keyattr => 'document'); insert($_) for @{$xml->{document}}; sub insert { my $hash = shift; my $sth = $dbh->prepare( 'insert into bar (' . join(',', keys %$hash) . ') values (' . join(',',map '?',keys %$hash) . ')' ); $sth->execute(values %$hash); } __DATA__ <documents> <document> <stayonhost>1</stayonhost> <staybelow>1</staybelow> <maxdepth>2</maxdepth> <name>Swedish Foo</name> <home_url>http://www.foo.se/bar/</home_url> <category>International</category> </document> <document> <stayonhost>0</stayonhost> <staybelow>0</staybelow> <maxdepth>3</maxdepth> <name>Swedish Bar</name> <home_url>http://www.bar.se/baz/</home_url> <category>National</category> </document> </documents>
Piece of cake. I can't help but feel that i am reinventing a wheel with my insert() sub however ...

UPDATE: May 2
Ahhh, how about a version with DBI::Wrap?

use DBI::Wrap; use XML::Simple; my $dbh = DBI::Wrap->new( ... ); $dbh->table('hacker'); my $xml = XMLin(\*DATA, keyattr => 'document'); $dbh->insert(Values => $_) for @{$xml->{document}}; __DATA__ (insert data from above snippet)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)