Hi,
XML-DOM-XPath seems to suit my needs well. It's easily installed and uses a well known interface. Still I seem to be stuck on an expression using >.
========
CPAN::Forum
XML-DOM-XPath - > operator problems
| Posted on Mon Feb 21 12:41:53 2005 by yishay |
| > operator problems |
|
Hi,
XML-DOM-XPath seems to suit my needs well. It's easily installed and uses a well known interface. Still I seem to be stuck on an expression using >. ========
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";
}
===================
I get: Can't locate object method "to_number" via package "XML::DOM::Element" at C:/Perl/site/lib/XML/XPath/Expr.pm line 450. Note that the same script using the '=' operator does work. I realize XML::XPath::Expr is an independent package. Maybe it could be changed to check type before calling to_number() method. Or there might be a way of changing XML::DOM::XPath. Or my script could be wrong? Any ideas? Should I report the bug? Thanks, Yishay |
| Write a response |
(0)
]