Skip Menu |

This queue is for tickets about the XML-LibXML CPAN distribution.

Report information
The Basics
Id: 12288
Status: rejected
Priority: 0/
Queue: XML-LibXML

People
Owner: Nobody in particular
Requestors: chris [...] prather.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.58
Fixed in: (no value)



Subject: using xpath on nodes with a default namespace fails
I'm having trouble getting xpath expressions to work against xml with a default namespace. I'm running the latest non-developer release of XML::LibXML and libxml2-2.6.16 from Gentoo's portage. I spoke with Nacho about this and he agree's it's a bug. I wrote a test showing the problem I'm having. #!/usr/bin/perl use strict; use XML::LibXML; use Test::More qw(no_plan); my $parser = new XML::LibXML; my $xml = <<''; <?xml version="1.0"?> <foo>bar</foo> my $xmlns = <<''; <?xml version="1.0"?> <foo xmlns="http://foo.com">bar</foo> my $dom = $parser->parse_string($xml); my $domns = $parser->parse_string($xmlns); is($dom->findvalue('/foo'), 'bar', 'Foo is Bar'); is($domns->findvalue('/foo'), 'bar', 'Foo is Bar'); # findvalue() is undef
From: Ben.Evans [...] morganstanley.com
[guest - Thu Apr 14 15:14:58 2005]: Show quoted text
> I'm having trouble getting xpath expressions to work against xml with > a default namespace. I'm running the latest non-developer release > of XML::LibXML and libxml2-2.6.16 from Gentoo's portage. I spoke > with Nacho about this and he agree's it's a bug. > > I wrote a test showing the problem I'm having. > > #!/usr/bin/perl > use strict; > use XML::LibXML; > use Test::More qw(no_plan); > > my $parser = new XML::LibXML; > > my $xml = <<''; > <?xml version="1.0"?> > <foo>bar</foo> > > my $xmlns = <<''; > <?xml version="1.0"?> > <foo xmlns="http://foo.com">bar</foo> > > my $dom = $parser->parse_string($xml); > my $domns = $parser->parse_string($xmlns); > > is($dom->findvalue('/foo'), 'bar', 'Foo is Bar'); > is($domns->findvalue('/foo'), 'bar', 'Foo is Bar'); # findvalue() is > undef
It also fails if you name the namespace: use XML::LibXML; use Test::More qw(no_plan); my $NS = "http://bar.com/"; my $xml_ns = qq[<?xml version="1.0"?> <x:bar xmlns:x="http://bar.com">1234</x:bar>]; my $parser = XML::LibXML->new(); my $doc = $parser->parse_string($xml_ns); is($doc->findvalue('/bar'), '1234', 'bar is 1234'); (perl 5.8, XML::LibXML 1.57, libxml2-2.6.6)