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

I'm trying to use the XML::RSS::Parser module to pull rss feeds which I eventually will try to put into a mysql database and since I don't really understand how to use this module I'm confused by an error I'm getting the code I'm using is :
#!/usr/bin/perl use strict; use LWP::UserAgent; use XML::RSS::Parser; my $agent = LWP::UserAgent->new; my $RSS = $agent->get( 'http://feeds.feedburner.com/BicyclemarksCommun +ique' ); my $rssresult = $RSS->content(); my $p = new XML::RSS::Parser; my $feed = $p->parsefile( $rssresult ); # output some values my $title = XML::RSS::Parser->ns_qualify('title',$feed->rss_namespace_ +uri); print $feed->channel->children($title)->value."\n"; print "item count: ".$feed->item_count()."\n\n"; foreach my $i ( $feed->items ) { map { print $_->name.": ".$_->value."\n" } $i->children; print "\n"; }
When I run it I get an error of "File name too long at ./rsscap line 13". How do I fix my code so I don't have to save the result out to a file before I parse it?

Replies are listed 'Best First'.
Re: RSS Parser
by jasonk (Parson) on May 28, 2005 at 05:31 UTC

    You aren't saving it to a file in between, you are taking then entire contents of the RSS feed, and passing it to XML::RSS::Parser as a filename to be parsed, hence it is telling you that the filename is too long. You want to use $p->parse($rssresult) instead of $p->parsefile($rssresult).


    We're not surrounded, we're in a target-rich environment!
Re: RSS Parser
by brian_d_foy (Abbot) on May 28, 2005 at 05:31 UTC

    The parsefile() method takes a file name, not the RSS file contents. I think you want parse() instead.

    --
    brian d foy <brian@stonehenge.com>