use strict; use DBI; use XML::XPath use XML::XPath::XMLParser; my $dbh = DBI->connect ("DBI:mysql:database", "root", "password", { RaiseError => 1, PrintError => 0}); my $xp = XML::XPath->new (filename => "input_file.xml"); my $nodelist = $xp->find ('//row'); foreach my $row ($nodelist->get_nodelist ()) { $dbh->do ("INSERT INTO users1 ( create_string, username) VALUES (?, ?)", undef, # no need for \%attr $row->find ("CreateDate")->string_value () =~ s/(\d\d\d\d-\d\d-\d\d)T(\d\d:\d\d:\d\d).*00/$1 $2/g, $row->find ("UserName")->string_value ()); } $dbh->disconnect ()