leonidlm has asked for the wisdom of the Perl Monks concerning the following question:
Hi All,
I have a strange problem. Please inspect the following code:
error in xpath expression //OverallConnectionPoolStatus/FlowRater[Name= ...
I decided to check this exact expression in the XML::XPath itself, and there, I have no errors, I even get a desired result! I used the following code:
I have a strange problem. Please inspect the following code:
When I run it on an xml file I receive:use XML::Twig::XPath; my $t = XML::Twig->new( twig_roots => { 'BalancerStatus/WebServer/OverallConnectio +nPoolStatus' => \§ion, }); $t->parsefile( 'localhost.xml'); # sub section { my ($t, $section) = @_; print $section->get_xpath( q{//OverallConnectionPoolStatus/FlowRat +er[Name='Total.IncomingReq']} ); $t->purge; }
error in xpath expression //OverallConnectionPoolStatus/FlowRater[Name= ...
I decided to check this exact expression in the XML::XPath itself, and there, I have no errors, I even get a desired result! I used the following code:
Strange! Can someone help ?use XML::XPath; use XML::XPath::XMLParser; my $xp = XML::XPath->new(filename => 'chunk.xml'); my $nodeset = $xp->find( q{//OverallConnectionPoolStatus/FlowRater +[Name='Total.IncomingReq']} ); # find all paragraphs foreach my $node ($nodeset->get_nodelist) { print "FOUND\n\n", XML::XPath::XMLParser::as_string($node), "\n\n"; }
Back to
Seekers of Perl Wisdom