Hi
I have a problem with an Xpath query that doesn't return a
result.
The xpath looks like this
/Grid/Cluster[ ClusterName/text() =
'CQUGRID01']/Database[Name/text() = 'CS89A2']/LinuxAppServer
and this works when using query the xml file with XPath
Explorer in Eclipse.
When I use that in a perl program I am working on it fails
to get a result
my perl command from the debugging looks like this
In the trace below I have removed the quotes from around the
xpath varables, which had no change on the problem.
43: my $query = "/Grid/Cluster[ ClusterName/text() =
$clusternode]/Database[Name/text() =
$_[0]]/LinuxAppServer";
DB<1> n
main::find_appserv_node(XpathTest.pl:44):
44: print $query . "n";
DB<1> n
/Grid/Cluster[ ClusterName/text() =
CQUGRID03]/Database[Name/text() = CS89A2]/LinuxAppServer
main::find_appserv_node(XpathTest.pl:45):
45: appnodes1 =
$config->findnodes($query);
DB<1> n
main::find_appserv_node(XpathTest.pl:46):
46: print appnodes1 ;
DB<1> n
main::find_appserv_node(XpathTest.pl:47):
47: if ( appnodes1){
DB<1> n
main::find_appserv_node(XpathTest.pl:41):
41: print "Getting AS ClusterNode:
" . $clusternode ."n";
DB<1> n
Getting AS ClusterNode: CQUGRID01
main::find_appserv_node(XpathTest.pl:43):
43: my $query = "/Grid/Cluster[ ClusterName/text() =
$clusternode]/Database[Name/text() =
$_[0]]/LinuxAppServer";
DB<1> n
main::find_appserv_node(XpathTest.pl:44):
44: print $query . "n";
DB<1> n
/Grid/Cluster[ ClusterName/text() =
CQUGRID01]/Database[Name/text() = CS89A2]/LinuxAppServer
main::find_appserv_node(XpathTest.pl:45):
45: appnodes1 =
$config->findnodes($query);
DB<1> s
XML::LibXML::Node::findnodes(/usr/lib/perl5/site_perl/5.8.5/
i386-linux-thread-multi/XML/LibXML.pm:878):
878: my ($node, $xpath) = _;
DB<1> x _
0 XML::LibXML: ocument=
SCALAR(0x8ee5d04)
-> 149996728
1 '/Grid/Cluster[ ClusterName/text() =
CQUGRID01]/Database[Name/text() = CS89A2]/LinuxAppServer'
DB<2> n
XML::LibXML::Node::findnodes(/usr/lib/perl5/site_perl/5.8.5/
i386-linux-thread-multi/XML/LibXML.pm:879):
879: my nodes = $node->_findnodes($xpath);
DB<2> s
XML::LibXML::Node::findnodes(/usr/lib/perl5/site_perl/5.8.5/
i386-linux-thread-multi/XML/LibXML.pm:880):
880: if (wantarray) {
DB<2> x $node
0 XML::LibXML: ocument=
SCALAR(0x8ee5d04)
-> 149996728
DB<3> x $xpath
0 '/Grid/Cluster[ ClusterName/text() =
CQUGRID01]/Database[Name/text() = CS89A2]/LinuxAppServer'
DB<4> n
XML::LibXML::Node::findnodes(/usr/lib/perl5/site_perl/5.8.5/
i386-linux-thread-multi/XML/LibXML.pm:881):
881: return nodes;
DB<4> x nodes
empty array
DB<5> n
main::find_appserv_node(XpathTest.pl:46):
46: print appnodes1 ;
DB<5> n
main::find_appserv_node(XpathTest.pl:47):
47: if ( appnodes1){
DB<5> n
main::find_appserv_node(XpathTest.pl:60):
60: if ( appnodes) {
DB<5> n
main::find_appserv_node(XpathTest.pl:70):
70: return appservnodes;
DB<5> n
main::(XpathTest.pl:23): foreach my $testnode( testnodes
){
DB<5> n
Debugged program terminated. Use q to quit or R to
restart,
use O inhibit_exit to avoid stopping after program
termination,
h q, h R or h O to get additional info.
DB<5>
This is very frustrating, and looks like a bug in LibXML,
but I will leave that as a doubt.
Maybe there is a better way to find the elements and return
the data.
Any help appreciated
Cheers
--
Peter McLarty
Technology Consultant
Brisbane Australia
MACM MIEE MACS
Membership Development Coordinator IEEE QLD Section
GOLD Affinity Group Chair IEEE QLD
===========================================
peter.mclarty pameacs.com +61402094238
===========================================
The sages do not consider that making no mistakes is a
blessing. They
believe, rather, that the great virtue of man lies in his
ability to
correct his mistakes and continually make a new man of
himself.
-- Wang Yang-Ming (1472-1529) Chinese Philosopher
_______________________________________________
Perl-XML mailing list
Perl-XML listserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs
|