Subject: | getNodeText doesn't return undef for nonexistent nodes |
Under XML::XPath 1.13, getNodeText is documented as:
Show quoted text
> Returns the text string for a particular XML node. Returns a string,
> or undef if the node doesn't exist.
However, it appears to return a defined value if the node doesn't exist. The enclosed new test script thus fails its last test.
use Test::More tests => 5;
BEGIN { use_ok 'XML::XPath' }
my $xp = XML::XPath->new(ioref => *DATA);
isa_ok($xp, 'XML::XPath');
my $text;
$text = $xp->getNodeText('//BBB[@id = "b1"]');
ok((defined $text), "text is defined for id that exists");
is($text, 'Foo');
$text = $xp->getNodeText('//BBB[@id = "b2"]');
ok((not defined $text), "text is not defined for id that does not exist");
__DATA__
<AAA>
<BBB id='b1'>Foo</BBB>
</AAA>