#!/usr/bin/perl -w # # opml2html.pl, (c) Jeremy Zawodny -- http://jerermy.zawodny.com/blog/ # # Updated by Michael Radwin (http://www.radwin.org/michael/blog/) # on Dec 26th, 2003 to include image size attributes and link # titles. # # You may distribute this code freely. It's not rocket science. # # Given an OPML file on stdin, produces an XHTML "blgoroll" fragment # suitable for inclusion on a weblog. Tested with AmphetaDesk and # Radio UserLand. # # Usage: opml2html.pl < foo.opml > bar.html # use strict; use XML::Simple; use Data::Dumper; use HTML::Entities; my $xml; { local($/) = undef; $xml = <>; } my $info = XML::Simple::XMLin($xml); my $data = $info->{body}->{outline}; my @list = sort { lc $a->{title} cmp lc $b->{title} } @$data; for my $item (@list) { my $title = encode_entities($item->{title}); my $h_url = $item->{htmlurl} || $item->{htmlUrl}; my $x_url = $item->{xmlurl} || $item->{xmlUrl}; my $descr = encode_entities($item->{description}); print qq[

]; print qq[\n]; print qq[$title

]; print "\n"; }