xpath problem with XML::XPath and LibXML

[email protected]
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
hi all,
Below is the xml I want to parse with XPath, however, I met some problems  
with both XML::XPath and XML::LibXML;

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"  
xmlns:db="http://www.douban.com/xmlns/"  
xmlns:gd="http://schemas.google.com/g/2005"
xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/">
<title>friends</title>
<author>
<link href="http://api.douban.com/people/ahbei" rel="self"/>
<link href="http://www.douban.com/people/ahbei/" rel="alternate"/>
<link href="http://t.douban.com/icon/u1000001-14.jpg" rel="icon"/>
<name>ahbei</name>
<uri>http://api.douban.com/people/1000001</uri>
</author>
<opensearch:startIndex>1</opensearch:startIndex>
<opensearch:itemsPerPage>2</opensearch:itemsPerPage>
<opensearch:totalResults>114</opensearch:totalResults>
<entry>
<id>http://api.douban.com/people/1010394</id>
<title>Engo</title>
<link href="http://api.douban.com/people/1010394" rel="self"/>
<link href="http://www.douban.com/people/akin/" rel="alternate"/>
<link href="http://t.douban.com/icon/u1010394-10.jpg" rel="icon"/>
<link href="http://www.halfull.cn" rel="homepage"/>
<content>
http://www.douban.com/group/topic/3750385/
</content>
<db:location id="beijing">beijing</db:location>
<db:uid>akin</db:uid>
</entry>
<entry>
<id>http://api.douban.com/people/1276180</id>
<title>wo</title>
<link href="http://api.douban.com/people/1276180" rel="self"/>
<link href="http://www.douban.com/people/movie007wn/" rel="alternate"/>
<link href="http://t.douban.com/icon/u1276180-40.jpg" rel="icon"/>
<content>
???????????????
</content>
<db:location id="beijing">beijing</db:location>
<db:uid>movie007wn</db:uid>
</entry>
</feed>

Here is the XML::XPath code:

my $xml = XML::XPath->new( xml => $string);
my $nodeset = $xml->findnodes('//entry');
foreach my $node ( $nodeset->get_nodelist){
print $node->findvalue('//title'),"\n";
}

I got
friendsEngowo
friendsEngowo
which are all the title nodes of this xml, it seems like each $node has all  
the information of this XML. Dose any one knows what the problem
is?


Then I try to use XML::LibXML instead, here is the code

my $xml = XML::LibXML->new->parse_string( $string);
my @nodeset = $xml->find('//entry');
print Dumper @nodeset;

I got
$VAR1 = bless( [], 'XML::LibXML::NodeList' );

which means I got nothing, entry nodes for this xml are not found, so can  
anybody help me?

_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.