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

Umm, that's the point - the code doesn't work - if it worked I wouldn't be asking how to fix it..

Replies are listed 'Best First'.
Re^3: XPath query issue...
by spstansbury (Monk) on Sep 02, 2009 at 18:31 UTC

    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)) { }

      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

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