Hi everyone, i'm trying to make a login function using perl and XML. I have a perl script that recieve an username ad a password and uses xpath to look for a node in a XML file containing the data. For some reasons the xpath fails and doesn't return any nodes. I'm sure the password and the username recieved by the script are correct. Here's the script and the XML file. Can someone please help me? I'm pretty noob and i cant figure this out.
my $file='../data/login.xml'; my $parser=XML::LibXML->new(); my $doc=$parser->parse_file($file) or die"err parser"; $doc->documentElement->setNamespace("http://www.crtp.it","p"); my $finded = $doc->findnodes("p:login/p:utenti[p:email ='$email' and +p:password='$digestpass']"); if($finded){ my $amministratore=$doc->findnodes("p:login/p:utenti[p:username =' +$email' and p:password='$digestpass']/p:admin"); my $sessione = CGI::Session->new(); my $user = $doc->findnodes("p:login/p:utenti[p:username ='$email' +and p:password='$digestpass']/p:nome"); $sessione->param("email","$email"); $sessione->param("amministratore","$amministratore"); $sessione->param("user","$user"); print $sessione->header(-location=>"fork.cgi"); }
finded remains empty. here's the XML
<?xml version="1.0" encoding="UTF-8"?> <p:login xmlns="http://www.crtp.it" xmlns:xsi="http://www.w3.org/2001/ +XMLSchema-instance" xmlns:p="http://www.crpt.com" xsi:schemaLocation= +"http://www.crpt.com login.xsd"> <utenti> <admin>n</admin> <email>geeno@gmail.com</email> <password>85136c79cbf9fe36bb9d05d0639c70c265c18d37 +</password> <nome>geeno</nome> <cognome>peeno</cognome> <sesso>Maschio</sesso> <dataNascita>26/10/1991</dataNascita> </utenti> <utenti> <admin>y</admin> <email>davide@gmail.com</email> <password>85136c79cbf9fe36bb9d05d0639c70c265c18d37 +</password> <nome>davide</nome> <cognome>santangelo</cognome> <sesso>Maschio</sesso> <dataNascita>26/10/1991</dataNascita> </utenti> </p:login>
In reply to Xpath not working by njack
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |