in reply to XPath not behaving as expected...

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.

Replies are listed 'Best First'.
Re^2: XPath not behaving as expected...
by spstansbury (Monk) on Jan 11, 2011 at 18:19 UTC

    Once again, thank you very much!

    Scott...