Skip Menu |

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

Report information
The Basics
Id: 14248
Status: resolved
Priority: 0/
Queue: XML-XPath

Owner: MANWAR [...]
Requestors: GLASSER [...] CPAN.ORG

Bug Information
Severity: Important
Broken in: 1.13
Fixed in: 1.19


Subject: getNodeText doesn't return undef for nonexistent nodes
Download (untitled) / with headers
text/plain 293b
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.
Download 31getNodeText.t
text/x-perl 432b
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>
Hi, Thanks for reporting the issue. I will act on it asap. Best Regards, Mohammad S Anwar
Download (untitled) / with headers
text/plain 310b
Updated pod for method getNodeText() to say it returns '' (empty string) if node doesn't exist. I don't want to change the behaviour and return undef if node doesn't exist as it might break/upset user relying on the distribution. I am going with safest route. Also adding unit test as you have kindly provided.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to