in reply to {KOHA}Parse XML and assign to variables.

Does your code work if you eliminate LWP::UserAgent and XML::Simple?

What are the values you get in $firstname, $lastname etc? What values get stored in the database?

What does AddMember do?

Most likely, the data structure you get back from XML::Simple is not what you expect. But as you don't show us the XML you download, it's hard to tell for us.

Replies are listed 'Best First'.
Re^2: {KOHA}Parse XML and assign to variables.
by scolife (Novice) on Sep 15, 2015 at 12:05 UTC
    I am expecting to get
    <to_user_info> <photo>http://webpage/getstpic.ashx?id=10010008460</photo> <lastname>asdasd</lastname> <firstname>asdasd</firstname> <sisiid>aB06B10253</sisiid> <school>aswe</school> <program>sw</program> <registerNr>89021800</registerNr> <phones/> <emails/> <userStatus> er</userStatus> <usertype>1</usertype> </to_user_info>
    If i eliminate LWP::UserAgent and XML::Simple from header section. It works.

      So, does it still work if you add XML::Simple in, without adding in LWP::UserAgent?

        Yeah It works
        #!/usr/bin/perl #script to do a borrower enquiry/bring up borrower details etc #written 20/12/99 by chris@katipo.co.nz # Copyright 2000-2002 Katipo Communications # Copyright 2013 BibLibre # # This file is part of Koha. # # Koha is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # Koha is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Koha; if not, see <http://www.gnu.org/licenses>. use CGI; use C4::Auth; use C4::Output; use C4::Items; use C4::Context; use LWP::Simple; #use XML::Simple; use XML::Parser; use Data::Dumper; use C4::Members; #use LWP::UserAgent; use C4::Branch qw(GetBranches); use utf8; my $input = new CGI; my $remoteip= $input->remote_host(); my ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "members/addfromsisi.tt" +, query => $input, type => "intranet", authnotrequired => 0, flagsrequired => {borrowers => 1}, }); my $rfid= $input->param('rfid'); my $op= $input->param('op'); # request my $ua = LWP::UserAgent->new; my $response = $ua->get("https://***************/studentservic +e/service.asmx/give_to_koha_byStudentCard?cardNR=$rfid&ip=$remoteip") +; my $xml=$response->content; my $xs = new XML::Simple(keeproot =>0,searchpath => ".",forcea +rray => 1,); my $ref = $xs->XMLin($xml); my $firstname=${$ref->{firstname}}[0]; my $lastname=${$ref->{lastname}}[0]; my $sisiid=${$ref->{sisiid}}[0]; my $school=${$ref->{school}}[0]; my $program=${$ref->{program}}[0]; my $registerNr=${$ref->{registerNr}}[0]; my $userStatus=${$ref->{userStatus}}[0]; my $usertype=${$ref->{usertype}}[0]; my $photo=${$ref->{photo}}[0]; my $branch=${$ref->{abbrevm}}[0]; my $op= $input->param('op'); # save when op= "save" my %newdata; if($op eq "save"){ %newdata =("cardnumber"=>"$rfid", "surname"=>"$lastname", "firstname"=>"$firstname", "initials"=>"$registerNr", "address"=>"$program", "userid"=>"$sisiid", "categorycode"=>'ST', "branchcode"=>'EZS', "password"=>'aaaaaaa' ); my $borrowernumber=&AddMember(%newdata); #PutPatronImage('aaaaaaaaa', 'image/jpeg', $imgfile); if (defined $borrowernumber) { my $q = new CGI; print $q->redirect(-uri=>"moremember.pl?borrowernumber +=$borrowernumber"); } }# save end $template->param( rfid=>$rfid, photo=>$photo, firstname=>$firstname, lastname=>$lastname, sisiid=>$sisiid, school=>$branch, program=>$program, registerNr=>$registerNr, userStatus=>$userStatus, usertype=>$usertype, remoteip=>$remoteip, op=>$op, res=> $imgfile, ); output_html_with_http_headers $input, $cookie, $template->output;