There are some obvious errors ; customer and supplier subroutines both have
$player->field

Regarding the client, joining the 3 xml files into one will not produce a valid xml file.
As a first step try this revised server code with xml from DATA . Just open URL in browser.

#!/usr/bin/perl use strict; use warnings; use CGI; use DBI; use XML::Twig; use CGI::Carp 'fatalsToBrowser'; my $cgi = CGI->new; print $cgi->header(-type => "text", -charset => "utf-8"); # change to POSTDATA my $xml = do { local $/; <DATA> };#$cgi->param("POSTDATA"); my $dashes = '-' x 50 ."\n"; print qq!XML received : $dashes $xml $dashes !; my $username = "user"; my $password = "password"; my $dsn = "dbi:mysql:twig:localhost"; my $dbh = DBI->connect($dsn,$username,$password) or die "Cannot connec +t to database: $DBI::errstr"; my $sql1 = 'INSERT INTO twig_test(name,ppg,rpg,apg,g,blk) VALUES(?,?,?,?,?,?)'; my $sth1 = $dbh->prepare($sql1); my $sql2 = 'INSERT INTO customer(first_name,last_name,dob,email) VALUES(?,?,?,?)'; my $sth2 = $dbh->prepare($sql2); my $sql3 = 'INSERT INTO supplier(name,address,tel_no) VALUES(?,?,?)'; my $sth3 = $dbh->prepare($sql3); #test if($dbh){ print "print successfully connected to the database\n$dashes"; } my $twig = new XML::Twig( twig_handlers => {player => \&player, customer => \&customer, supplier => \&supplier} ); $twig->parse($xml); #$twig->print; sub player { my ($twig,$player) = @_; my @f=(); for ('name','ppg','rpg','apg','g','blk'){ push @f, $player->field($_); print "Player $_ : $f[-1]\n"; } $sth1->execute(@f) or die $DBI::errstr; print $dashes; } sub customer { my ($twig,$customer) = @_; my @f=(); for ('first_name','last_name','dob','email'){ push @f, $customer->field($_); print "Customer $_ : $f[-1]\n"; } $sth2->execute(@f) or die $DBI::errstr; print $dashes; } sub supplier { my ($twig,$supplier) = @_; my @f=(); for ('name','address','tel_no'){ push @f, $supplier->field($_); print "Supplier $_ : $f[-1]\n"; } $sth3->execute(@f) or die $DBI::errstr; print $dashes; } __DATA__ <?xml version="1.0"?> <root> <customer> <first_name>Frank</first_name> <last_name>Sanbeans</last_name> <dob>3/10</dob> <email>frank@example.com</email> </customer> <stats> <player><name>Houston,Allan</name><g>69</g><ppg>20.1</ppg><rpg>3.4</rp +g><apg>2.8</apg><blk>14</blk></player> <player><name>Sprewell, Latrell</name><g>69</g><ppg>19.2</ppg><rpg>4.5 +</rpg><apg>4.0</apg><blk>15</blk></player> <player><name>Ewing, Patrick</name><g>49</g><ppg>14.6</ppg><rpg>10.0</ +rpg><apg>1.0</apg><blk>68</blk></player> </stats> <supplier-data> <supplier> <name>Supplier 1</name> <address>Address 1</address> <tel-no>012345</tel-no> </supplier> </supplier-data> </root>

poj

In reply to Re^2: unable to pass data by poj
in thread unable to pass data by ashishg0310

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.