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;

In reply to Re^4: {KOHA}Parse XML and assign to variables. by scolife
in thread {KOHA}Parse XML and assign to variables. by scolife

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.