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

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.