in reply to Xpath not working

Yep, what the other Anon said. Here's the relevant code on how to actually do it:

my $xpc = XML::LibXML::XPathContext->new($doc); $xpc->registerNs('p', 'http://www.crtp.it'); $xpc->registerNs('p2', 'http://www.crpt.com'); my $finded = $xpc->findnodes("/p2:login/p:utenti[p:email='$email' and +p:password='$digestpass']");

Replies are listed 'Best First'.
Re^2: Xpath not working
by Anonymous Monk on Mar 27, 2014 at 20:50 UTC

    To correct my first sentence of the parent and expand the explanation a little:

    Your line $doc->documentElement->setNamespace("http://www.crtp.it","p"); does not work, and the documentation of XML::LibXML::Element->setNamespace explains why:

    The function fails if it is required to create a declaration associating the prefix with the namespace URI but the element already carries a declaration with the same prefix but different namespace URI.

    Which means you can't re-use the "p" prefix as it's already in use on the element; you'd have to pick a different prefix, then the setNamespace call would work and you wouldn't need to do registerNs on two namespaces.

    However, you would still need to make one XML::LibXML::XPathContext->registerNs set-up as shown in the parent.

    So TIMTOWTDI; personally I wouldn't manipulate the XML, but adjust my XPath to fit the XML (this is the solution shown in the parent, and you could remove the setNamespace call from your code).