On Oct 14, H S said:
Could someone help point out how to use scalar within Xpath query? I need to
use $script in the query but it returns nothing.
I am somewhat confused about the interpolation in this case.
use XML::XPath;
my $xp = XML::XPath->new(filename => '/dssweb/prog/navi/links.xml');
my $script = "/cgi-bin/rates/showrate";
my $nodeset = $xp->findnodes('/navigator/nav_group/[EMAIL PROTECTED] =
"$script"] |
/navigator/nav_group/nav/[EMAIL PROTECTED] = "$script"]');
Variables won't expand in single quotes, and putting double quotes INSIDE
single quotes won't help either. You'll have to use double-quotes around
the entire string and escape whatever shouldn't be interpolated:
$xp->findnodes("/navigator/nav_group/[EMAIL PROTECTED] = '$script']");
Try that. I don't see anything explaining the syntax of an XML path, so I
don't really know what *I'm* doing.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://www.perlmonks.org/ % have long ago been overpaid?
http://princeton.pm.org/ % -- Meister Eckhart
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>