|
|
 |
perl-xml
Can I use a variable in an xpath?
by Amanda Hubbard other posts by this author
May 25 2006 1:37PM messages near this date
view in the new Beta List Site
RE: case insensitive searching
|
Re: Can I use a variable in an xpath?
& XSLT I'm trying to find a value in an XML document using XPATH. I want to use a variable
that contains the path because I will be looping through several paths and passing them to a
method. Is this valid?
##$browser is an LWP::UserAgent object
my $URL = "$protocol\://$host:$port/sdk/$parent?ip=$ip";
my $response = $browser-> get($URL);
$searchPath="chassis/ramMemory/size";
my $parser = XML::XPath::XMLParser-> new(xml => $response->content);
my $root_node = $parser-> parse;
my $xp = XML::XPath-> new(context => $root_node);
###Is there a way to make the following work?
my $nodeset=$xp-> find('$searchPath[@value]');
###Rather than:
my $nodeset=$xp-> find('chassis/ramMemory/size[@value]');
The errror I am getting is:
Can't call method "isa" on an undefined value at C:/Perl/site/lib/XML/XPath/Expr.pm line 142
.
Any pointers would be greatly appreciated.
Thanks,
Amanda
Thread:
Amanda Hubbard
Grant McLean
A. Pagaltzis
Grant McLean
Shlomi Fish
Mark - BLS CTR Thomas
|
|
|
 |
|