in reply to Re^2: XPath query issue...
in thread XPath query issue...

The issue is just that - the @ is being interpreted as a global symbol and it should behave as a XPATH symbol signifying the attribute.

my $query = "/nvd/entry[@id = $cve_id]"; my $xp = XML::XPath-> new(filename => "$data_file"); foreach my $cve_entry ($xp->findnodes($query)) { }

Replies are listed 'Best First'.
Re^4: XPath query issue...
by derby (Abbot) on Sep 02, 2009 at 19:11 UTC

    You need to escape the @ somehow so perl does not try to interpolate it:

    my $query = '/nvd/entry[@id = ' . $cve_id . ']';
    or
    my $query = "/nvd/entry[\@id = $cve_id]";

    -derby
Re^4: XPath query issue...
by Corion (Patriarch) on Sep 02, 2009 at 19:21 UTC

    ... which is what both use strict; and use warnings; would have told you, if you had used them.