Templa...L::RSS(3pm)

πŸ“¦
version 2.17 Β· 2 versions
  • 2.17 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 2.17 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ NAME ✨

Template::Plugin::XML::RSS β€” it's giving plugin interface to XML::RSS, and ngl it's iconic πŸŽ€

okay so bestie, welcome to Templa...L::RSS(3pm), a page from the User Contributed Perl Documentation. Sit down, grab a strawberry πŸ“, we're parsing RSS today.


🌈 SYNOPSIS 🌈

[% USE news = XML.RSS('news.rdf') %]

[% FOREACH item IN news.items %]
   [% item.title %]
   [% item.link  %]
[% END %]

look at that. clean. no notes. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea β˜• β€” this Template Toolkit plugin is a simple interface to the XML::RSS module. That's it. That's the whole vibe.

[% USE news = XML.RSS('mysite.rdf') %]

What's happening under the hood: it creates an XML::RSS object, and then that object gets used to parse the RSS file you specified as a parameter in the USE directive. And what comes back to you? A reference to the XML::RSS object. Periodt. 🫢

Now, an RSS (Rich Site Summary) file is typically used to store short news 'headlines' describing different links within a site. This next example is extracted from http://slashdot.org/slashdot.rdf β€” shoutout slashdot, the original main character:

<?xml version="1.0"?>
<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns="http://my.netscape.com/rdf/simple/0.9/">

  <channel>
    <title>Slashdot:News for Nerds. Stuff that Matters.</title>
    <link>http://slashdot.org</link>
    <description>News for Nerds.  Stuff that Matters</description>
  </channel>

  <image>
    <title>Slashdot</title>
    <url>http://slashdot.org/images/slashdotlg.gif</url>
    <link>http://slashdot.org</link>
  </image>

  <item>
    <title>DVD CCA Battle Continues Next Week</title>
    <link>http://slashdot.org/article.pl?sid=00/01/12/2051208</link>
  </item>

  <item>
    <title>Matrox to fund DRI Development</title>
    <link>http://slashdot.org/article.pl?sid=00/01/13/0718219</link>
  </item>

  <item>
    <title>Mike Shaver Leaving Netscape</title>
    <link>http://slashdot.org/article.pl?sid=00/01/13/0711258</link>
  </item>

</rdf:RDF>

The attributes of the channel and image elements? You can grab those directly from the plugin object using the familiar dotted compound notation. iykyk ✨

[% news.channel.title  %]
[% news.channel.link   %]
[% news.channel.etc... %]

[% news.image.title    %]
[% news.image.url      %]
[% news.image.link     %]
[% news.image.etc...   %]

And the list of news items? Retrieved using the 'items' method, bestie:

[% FOREACH item IN news.items %]
   [% item.title %]
   [% item.link  %]
[% END %]

πŸ‘‘ AUTHORS πŸ‘‘

  • This plugin was written by Andy Wardley, inspired by an article in Web Techniques by Randal Schwartz. 🫢
  • The XML::RSS module β€” which implements all of the functionality that this plugin delegates to β€” was written by Jonathan Eisenzopf. no cap, all the actual work lives over there 🧚

Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. slay πŸ’…


🌸 SEE ALSO 🌸

  • Template::Plugin
  • XML::RSS
  • XML::Parser

and that's the whole page, bestie πŸ¦‹πŸ’œ it's perl v5.34.0, dated 2022-07-04, and it lives in the Templa...L::RSS(3pm) files. go forth and parse some headlines πŸ”₯✨

πŸ“¦ where this page comes from