subeen has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to parse a RSS file using XML::RSS but got stuck when I tried to read the following from items:
I tried $media_keyword = $item->{'media:keywords'}; to read the keywords but it shows nothing. I also want to read the media content url. Please see the example in http://www.feedforall.com/mediarss.htm I am trying to parse similar rss.<media:content url="http://www.media.com" type="video/windows-wmv" med +ium="video" width="416" height="312"> <media:keywords>Bill, Concert with Bill</media:keywords> <dcterms:valid> start=2005-06-13T00:00:00; end=2005-12-31T00:00:00; scheme=W3C-DTF </dcterms:valid> </media:content>
Made some progress with add_module.
It prints title and media_keywords, but doesn't show anything for media_content_url. BTW. The RSS I am trying to parse is RSS 2$rss->add_module(prefix=>'dc', uri=>"http://purl.org/dc/terms/"); $rss->add_module(prefix=>'media', uri=>"http://search.yahoo.com/mrss") +; $rss->parse($raw); foreach my $item (@{$rss->{'items'}}) { $title = $item->{'title'}; $media_content_url = $item->{'media'}->{'content'}->{'url'}; $media_keywords = $item->{'media'}->{'keywords'}; print $title, "\n"; print $media_content_url, "\n"; print $media_keywords, "\n"; }
Thanks, Subeen.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: RSS Parse Problem with XML::RSS
by hossman (Prior) on Sep 16, 2007 at 07:35 UTC | |
by subeen (Initiate) on Sep 17, 2007 at 07:07 UTC | |
by moritz (Cardinal) on Sep 17, 2007 at 08:51 UTC | |
by subeen (Initiate) on Sep 17, 2007 at 10:40 UTC |