Posted on 2005-02-21 10:41:53-08 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
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.