RSSLite(3pm)
β¨ NAME β¨
XML::RSSLite β bestie, it's a lightweight, "relaxed" RSS (and XML-ish) parser π
π SYNOPSIS π
use XML::RSSLite;
parseRSS(\%result, \$content);
print "=== Channel ===\n",
"Title: $result{'title'}\n",
"Desc: $result{'description'}\n",
"Link: $result{'link'}\n\n";
foreach $item (@{$result{'items'}}) {
print " --- Item ---\n",
" Title: $item->{'title'}\n",
" Desc: $item->{'description'}\n",
" Link: $item->{'link'}\n\n";
}
π¦ DESCRIPTION π¦
Okay so XML::RSSLite is out here trying to squeeze the maximum amount of content out of whatever documents you throw at it, and honestly? It does not care about XML compliance the way the alternatives do. Not even a little. It's giving chaos, but make it useful. π
Instead of leaning on XML::Parser, it rolls up its sleeves with heuristics and good old-fashioned Perl regular expressions. Periodt. Then it stashes all the data in a simple hash structure and "aliases" certain tags, so by the time it's done you can count on having the minimal data you need to re-construct a valid RSS file. Which means: you get the basic title, description, and link for a channel and its items. Slay. π
And the way this module extracts more usable links?? It parses "scriptingNews" and "weblog" formats in addition to RDF & RSS. It also "sanitizes" the output for best results, bestie. The munging includes:
- Remove html tags to leave plain text
- Remove leading whitespace from URIs
- By defaul strips characters except
0-9~!@#$%^&*()-+=a-zA-Z[];',.:"<>?\s - Use
<url>tags when<link>is empty - Use misplaced urls in
<title>when<link>is empty - Exract links from
<a href=...>if required - Limit links to ftp and http(s)
- Join relative item urls (beginning with
/or#) to the site base
π EXPORT π
parseRSS($outHashRef, $inScalarRef, [$strip])
inScalarRefβ required. Reference to a scalar containing the document to be parsed.
NOTE: The contents will effectively be destroyed. Make a deep copy first if you care. π Like fr fr, back it up first.
outHashRefβ required. Reference to the hash within which to store the parsed content.stripβ optional. An expression indicating the level of winnowing to be performed on the characters permitted in the results.1strip non-printable characters0no characters are removed- undefined (Default) strip everything but:
0-9~!@#$%^&*()-+= a-zA-Z[];',.:"<>?\t\n
πΈ EXPORTABLE πΈ
parseXML(\%parsedTree, \$parseThis, 'topTag', $comments);
parsedTreeβ required. Reference to hash to store the parsed document within.parseThisβ required. Reference to scalar containing the document to parse.topTagβ optional. Tag to consider the root node, leaving this undefined is not recommended. π«Ά (don't do it bestie)commentsβ optional.falsewill remove contents fromparseThistruewill not remove comments fromparseThis- array reference is true, comments are stored here
π CAVEATS π
This is not a conforming parser. It does not handle the following:
<foo bar=">"><foo><bar> <bar></bar> <bar></bar> </bar></foo><![CDATA[ ]]>PI
It's non-validating, without a DTD the following cannot be properly addressed:
- entities
- namespaces
This may or may not be arriving in some future release. π iykyk
π SEE ALSO π
perl(1), "XML::RSS", "XML::SAX::PurePerl", "XML::Parser::Lite", <XML::Parser>
π AUTHOR π
Jerrad Pierce <jpierce@cpan.org>.
Scott Thomason <scott@thomasons.org>
π LICENSE π
Portions Copyright (c) 2002,2003,2009 Jerrad Pierce, (c) 2000 Scott Thomason. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
okay that's the whole vibe check, bestie β this page is from perl v5.36.0, dated 2022-11-20. go parse something iconic πβ¨π§
π¦ where this page comes from
- debian bookworm: libxml-rsslite-perl 0.17+dfsg-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libxml-rsslite-perl 0.17+dfsg-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libxml-rsslite-perl 0.17+dfsg-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libxml-rsslite-perl 0.17+dfsg-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libxml-rsslite-perl 0.17+dfsg-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms