in reply to How do you get attribute values using XML::LibXML
In addition to what's been said, it makes no sense to use an xpc in one place and not the other.
my $xc = XML::LibXML::XPathContext->new($root); $xc->findnodes('/HOSTNAME/PATROL/ACL/USERNAME') $sections->findnodes('./PERMISSION')
should be
$root->findnodes('/HOSTNAME/PATROL/ACL/USERNAME') $sections->findnodes('./PERMISSION')
or
my $xc = XML::LibXML::XPathContext->new( $root ); $xc->findnodes('/HOSTNAME/PATROL/ACL/USERNAME') $xc->findnodes('./PERMISSION', $sections)
An xpc isn't needed here since your XML doesn't use namespaces, but there's no harm in using one. Just be consistent about it.
Note that the leading to "./" is useless (whether an xpc is used or not). The following will do:
$xc->findnodes('PERMISSION', $section)
|
|---|