Subject: | > operator |
XML-DOM-XPath version 0.07
OS: winXP
perl -v: 5.8.4
description:
some xpath expressions containing '>', '>=', '<',
'<=' operators trigger an error:
Can't locate object method "to_number" via package "XML::DOM::Element" at C:/Perl/site/lib/XML/XPath/Expr.pm line 450.
('=' operator seems to work fine on same cases)
Example code:
========
<code>
use XML::DOM::XPath;
my $xmlStr = q{<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd country="USA">
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<price>10.90</price>
</cd>
<cd country="UK">
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<price>8.70</price>
</cd>
<cd country="USA">
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<price>9.90</price>
</cd>
</catalog>};
my $dom = XML::DOM::Parser->new();
my $doc = $dom->parse($xmlStr);
# '/catalog/cd[price=9.90]' works but '/catalog/cd[price<9.90]' doesn't
foreach my $node ($doc->findnodes('/catalog/cd[price<9.90]') )
{
print $node->getAttribute('country'), "\n";
}
</code>
===================