Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: XPath query issue...

by spstansbury (Monk)
on Sep 02, 2009 at 18:21 UTC ( [id://792985]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://792985]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-19 22:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found