in reply to Can't read xml after linking schema

The main problem is that you add not only the link to the schema, but also a namespace to your document. To handle documents containing namespaced elements, you have to use XML::LibXML::XPathContext:
#!/usr/bin/perl use warnings; use strict; use XML::LibXML; my ($userok, $passok) = (1, 0); my $digestuser = 'dado'; my $digestpass = 'cane'; my $file = 'user.xml'; my $parser = 'XML::LibXML'->new; my $doc = $parser->parse_file($file); my $root = $doc->getDocumentElement; my $xpc = 'XML::LibXML::XPathContext'->new; $xpc->registerNs('p', 'http://www.progetto.com'); for my $u ($xpc->findnodes('p:userlist/p:user', $doc)) { print "inside-cycle"; my ($property) = $xpc->findnodes('p:username', $u); if ($property->textContent eq $digestuser) { print $userok; ($property) = $xpc->findnodes('p:password', $u); if ($property->textContent eq $digestpass) { $passok = 1; print "i did it"; } last } }

The wrapper XML::XSH2 simplifies the code to

open user.xml ; my $digestuser = 'dado' ; my $password = 'cane' ; my $passok ; if p:userlist/p:user[p:username=$digestuser and p:password=$digestpass +] $passok = 1 ;
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Can't read xml after linking schema
by njack (Novice) on Jan 28, 2014 at 16:07 UTC

    and what if I remove the line with the namespace? could it cause trouble?

      It can cause serious trouble to any other code reading the file - if the code expected the namespace and it wasn't present, the code wouldn't find any nodes.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re^2: Can't read xml after linking schema
by njack (Novice) on Jan 28, 2014 at 16:15 UTC

    anyway it works and i f*****g love you, i'd buy you a lifetime supply of beer

      No jokes. I am from the Czech Republic, we drink several litres a day!
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ