Can someone help me please? I need to replace an XML node using Perl with the XML::LibXML module
This is the fragment of the XML file:
<utenti>
<utente>
<username>amministratore</username>
<useremail>[email protected]</useremail>
<password>0000</password>
</utente>
</utenti>
And I need to replace the value of the password.
In particular I have to find in the XML file the user with a particular username (given by the cookie $userCookie) and replace his password with the variable $newPSW.
I've tried this:
my $psw = $doc->findnodes("/utenti/utente[username=\"$userCookie\"]/password");
my $parent = $psw->parentNode;
$parent->removeChild($psw);
my $password = XML::LibXML::Element->new('password');
$password->appendText( $newPSW );
$parent->appendChild($password);
but everytime the browser give me the following error:
Can't locate object method "parentNode" via package "XML::LibXML::NodeList"
It seems to no find any method I use.
Can someone help?