I took over the XML::RSS module from Jonathan Eisenkopf thinking I could make a couple of quick fixes, release a new version, and everyone would be happy.
Instead, all sorts of other people came out of the woodwork with even more things to add. I just added them to the SourceForge project, which now has 6 members, and some of them have already committed their own changes.
I cleared one of the tickets in RT, and now I have one left, but one of the project members has a patch for this too. It is a little more complicated so I cannot clear the ticket right away.
Anyone interested in working on some part of XML:RSS? We could use help with almost anything, including maintaining a useful and visually pleasing website, tutorial writer, and project historian. Let's make XML::RSS the gold standard again. Volunteers?
This auto-populates the namespaces with the declared namespaces. So this file has:perl -MXML::RSS -MLWP::Simple -MData::Dumper -le '$t = get("http://freshmeat.net/backend/fm-releases-themes.rdf"); $x = new XML::RSS; $x->parse($t); for (keys %{$x->{namespaces}}) { next if $_ eq "rdf" || $_ eq "#default" || exists $x->{modules}{$x->{namespaces}{$_}}; $x->add_module(prefix => $_, uri => $x->{namespaces}{$_}) }; $x = new XML::RSS; $x->parse($t); print Dumper $x->{items}[0]'
And normally, XML::RSS just puts http://freshmeat.net/backend/fm-releases-0.1.dtd as the namespace for the items belonging to that module. That code above creates an fm namespace automatically (and then both work).xmlns:fm="http://freshmeat.net/backend/fm-releases-0.1.dtd"
Re:Feature request
brian_d_foy on 2002-11-14T21:38:37
That's a pretty long one-liner:)
Let me restate the request to see if I understand what you want:
XML::RSS should access Freshmeat's feed and automatically pull out whatever is in xmlns:fm, then add that as a module.
I do not want to do that for every object. Perhaps a more specific method like "add_freshmeat" so the module only loads LWP if you specifically want that to happen.
I can also add any common, but missing, namespaces to the default list.
I'm fairly new to the RSS world, so someone needs to point out the land mines before I do this.:) Re:Feature request
pudge on 2002-11-14T22:07:41
No, lemme try again.I just want to have add_module() called automatically for every nonstandard module in the feed. The real important code is here:
This does not need to invoke LWP. The only practical effect is that instead of someone needing to do this:# loop over existing namespaces
for my $ns (keys %{$rss->{namespaces}}) {
# skip default namespaces
next if $ns eq "rdf"
|| $ns eq "#default"
|| exists $rss->{modules}{ $ns->{namespaces}{$ns} };
$rss->add_module(prefix => $ns, uri => $rss->{namespaces}{$ns})
}They can do this:my $ns = 'http://freshmeat.net/backend/fm-releases-0.1.dtd';
for my $item ( @{$rss->{items}} ) {
print $item->{$ns}{screenshot_url};
}The one-liner:for my $item ( @{$rss->{items}} ) {
print $item->{fm}{screenshot_url};
}A patch implementing the code near the top would ideally skip the 5th item, and do the 3rd and 4th inside the 2nd. I believe I asked once for this to be included, but the response back was that one should know in advance what modules one is expecting. That is, you can all add_module before parsing the RSS. But a lot of times, you don't know what namespaces you will be expecting. Maybe a flag in the new constructor, add_modules => 1, or something, would be in order.
- fetches the RSS
- parses the RSS
- looks for nonstandard namespaces
- adds each namespaces with add_module (which sets up the fm => 'http://freshmeat.net/backend/fm-releases-0.1.dtd' mapping)
- reparses the XML
- uses the new RSS
Re:Feature request
brian_d_foy on 2002-11-14T22:25:52
Okay, I think I got this now. Automatically call add_module() for all of the namespaces in the file I have to parse. That makes sense.
Would you like to paste this into RT as a feature request? it's not going to happen this week because we have a long queue of patches for broken things (which come first).Re:Feature request
pudge on 2002-11-18T15:23:38
Added, thanks.