Re: xpath problem with XML::XPath and LibXML

Aristotle Pagaltzis <[email protected]>
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
* [email protected] <[email protected]> [2009-06-21 12:50]:
> 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?

XML::XPath is buggy. It shouldn’t produce any output for your
expession.

> 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?

This is correct behaviour. Björn told you the solution; see
<http://plasmasturm.org/log/259/> for some more background and
some example code.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>
_______________________________________________
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.