s/findvalue/findnodes/. It's also very silly to do the search twice.
if ( $xc->findnodes( 'advisories/cve', $vuln )) { for ( $xc->findvalue( 'advisories/cve', $vuln )) { push ( @cve_records, $_ ); } }
should be
for my $cve_node ($xc->findnodes('advisories/cve', $vuln)) { push @cve_records, $cve_node->textContent(); }
By the way,
$fnd_vuln_id = $_->findvalue('./@id');
should be
my $fnd_vuln_id = $_->findvalue('./@id');
and it can be simplified to
my $fnd_vuln_id = $_->findvalue('@id');
and even to
my $fnd_vuln_id = $_->getAttribute('id');
By the way, it would probably make more sense to load the nodes /audit/vulnerabilities/vuln into a hash (keyed by the id attribute) before the loop instead of repeatedly searching the tree inside the loop.
Update: Added notes.
In reply to Re: XPath not behaving as expected...
by ikegami
in thread XPath not behaving as expected...
by spstansbury
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |