philgyford has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to fetch and parse an Atom feed using XML::Atom::Feed and the code below:

#!/usr/bin/perl -w use strict; use XML::Atom::Feed; my $feed = XML::Atom::Feed->new('http://mildlydiverting.blogspot.com/a +tom.xml'); for my $entry ($feed->entries()) { print $entry->title()."\n"; }

This works fine on my local machine, but on my server I get:

Cannot open file 'http://mildlydiverting.blogspot.com/atom.xml' at /home/philg/scripts/extlib/XML/XPath.pm line 53.

It seems that my local machine has LibXML, but the server doesn't. So on the server XML::Atom::Feed is falling back to use XPath instead. But for some reason XPath is being told to fetch the Atom feed from the remote URL, which it isn't designed to do.

My Perl skills aren't sufficient for me to work out where things are going wrong in XML::Atom::Feed, if that's the culprit... any ideas how I can get this working without LibXML? Many thanks.

(FWIW, I was originally trying to debug this problem while using XML::Feed, and tracked the problem back to this point.)

Replies are listed 'Best First'.
Re: XML::Atom::Feed with XML::XPath not fetching feed
by elmex (Friar) on Apr 19, 2008 at 16:47 UTC

    I looked into it for a sec., I already had problems with XML::Atom too. At least the error goes away if you pass an URI object into the constructor of XML::Atom::Feed:

    #!/usr/bin/perl -w use strict; use URI; use XML::Atom::Feed; my $feed = XML::Atom::Feed->new(URI->new ('http://mildlydiverting.blog +spot.com/atom.xml')); for my $entry ($feed->entries()) { print $entry->title()."\n"; }

    UPDATE: I spent some more time with it, but I couldn't find out more in the limited time. I suggest you either install LibXML or try to report the bug via rt.cpan.org at XML-Atom on CPAN, or mail it directly to the author (which maybe has a higher chance of success :)

      I may not be able to get LibXML installed on this server unfortunately, but I'll ask.

      It doesn't look like bug-fixing has been much of a priority on XML::Atom, given there are bugs reported there unresolved from 2-3 years ago, but worth I try I guess...

      Thanks for trying.