Subject: | error messages when searching with xpath attributes |
My program did this:
@nodes = $t->match("//div[\@id='searchSummary']");
# $t is an Class::XPath instance
and produced a lot of errors like this:
Use of uninitialized value in string eq at /usr/lib/perl5/site_perl/5.8.1/Class/XPath.pm line 206.
Use of uninitialized value in string eq at /usr/lib/perl5/site_perl/5.8.1/Class/XPath.pm line 206.
Use of uninitialized value in string eq at /usr/lib/perl5/site_perl/5.8.1/Class/XPath.pm line 206.
I fixed it with this:
203a204,205
Show quoted text
>
> if(! defined($value) || $value eq "") { next; }
Not all children of the node in question had the attribute I was comparing on, this is what caused the problem.
This fix needs to go into the next release of Class::XPath because if I
install the new version through CPAN and this same problem crops up I will be quite irate.
This was perl 5.8.7 on linux 2.6 with Class-XPath-1.4, but I think this problem would occur across all platforms
Thanks