githubEdit

rssRSS

RSS/Atom feed module for BoxLang

📡 A comprehensive RSS/Atom feed module for BoxLang that brings full-featured feed reading and creation capabilities to your applications!

This module provides powerful RSS and Atom feed capabilities to the BoxLangarrow-up-right language, making it easy to read, parse, create, and manage syndication feeds with minimal code.

✨ Features

  • 📖 Read: Parse RSS 2.0, RSS 1.0 (RDF), and Atom feeds from URLs or files

  • ✍️ Create: Generate RSS 2.0 and Atom feeds with full metadata support

  • 🎙️ iTunes Podcast: Auto-detect and parse iTunes podcast extensions (23 additional fields)

  • 📹 Media RSS: Auto-detect and parse Media RSS extensions (thumbnails, content, player)

  • 🔄 Multiple Sources: Read from multiple feed URLs simultaneously and merge results

  • 🎯 Filtering: Apply custom filters to feed items during reading

  • 📄 Pagination: Limit items with maxItems parameter

  • 🔌 Flexible Output: Return results as structs, save to files, or get raw XML

  • 🏢 Enterprise Grade: Built and Supported by Ortus Solutions

  • 🔁 CFML Compatible: Drop-in replacement for CFML's cffeed tag

🥊 What's Included

This module provides the following BoxLang functions and components:

Built-In Functions (BIFs)

  • rss() - Simple function for reading RSS/Atom feeds with minimal configuration

Components

  • <bx:feed> - Full-featured component for reading and creating RSS/Atom feeds with extensive configuration options

Both the BIF and component support:

  • Reading RSS 2.0, RSS 1.0 (RDF), and Atom feeds

  • Creating RSS 2.0 and Atom feeds

  • iTunes podcast and Media RSS extensions

  • Multiple output formats and filtering options

📦 Installation

Install via CommandBox

If you are using CommandBox for your web applications, simply run:

The module will automatically register and be available as bxrss in your BoxLang applications.

🚀 Quick Start

Using the BIF (Easiest Way)

The simplest way to read an RSS feed is with the rss() function:

Using the Component

You can also use the <bx:feed> component for more control:

That's it! 🎉 You now have feed data parsed and ready to use.

💡 Pro Tip: The rss() BIF is perfect for quick feed reading, while the component gives you more options like multiple output variables, file writing, and creating feeds.

🔧 Feed Actions

The module supports two core operations:

📖 Read

Parse existing RSS/Atom feeds from URLs or files.

  • Use Case: Display blog posts, news articles, podcast episodes

  • Returns: Struct with items array and channel metadata

  • Features: Auto-detection of extensions, filtering, pagination, multiple output options

  • Extension Support: Automatically includes iTunes podcast and Media RSS fields when present

✍️ Create

Generate new RSS/Atom feeds from your data.

  • Use Case: Expose your content as RSS/Atom feeds, create podcasts

  • Returns: XML string, file output, or both

  • Features: Full metadata control, multiple item formats, character escaping

  • Formats: RSS 2.0 or Atom

💡 Examples

Basic Examples

📖 Simple Feed Read

Read and display feed items:

💡 Use Case: Display latest blog posts or news articles.

🎙️ Read iTunes Podcast Feed

Automatically detects and includes iTunes podcast fields:

💡 Use Case: Display podcast episodes with rich metadata.

📹 Read Media RSS Feed

Automatically detects and includes Media RSS thumbnail/content fields:

💡 Use Case: Display video feeds with thumbnails.

🎯 Filtered Feed Reading

Apply custom filters to feed items:

💡 Use Case: Display latest N items from a feed.

📄 Multiple Output Options

Use different output variables simultaneously:

💡 Use Case: Flexible data access for different use cases.

✍️ Create RSS Feed

Generate an RSS 2.0 feed from your data:

💡 Use Case: Expose your content as an RSS feed.

Advanced Examples

🎙️ Create iTunes Podcast Feed

Generate a podcast feed with iTunes extensions:

💡 Use Case: Create a podcast feed for Apple Podcasts, Spotify, etc.

🔄 Read Multiple Feeds

Merge items from multiple feeds:

💡 Use Case: Create a feed aggregator or news reader.

📊 Create Feed from Query

Generate feed from database query results:

💡 Use Case: Generate feeds from database content.

🌐 Custom User Agent

Use custom User-Agent for HTTP requests:

💡 Use Case: Identify your application to feed providers.

🎯 Extension Auto-Detection

How It Works

The RSS module automatically detects and includes extension fields (iTunes podcast, Media RSS) when they are present in a feed, without requiring you to explicitly enable them.

Auto-Detection Process:

  1. When no itunes or mediaRss flags are specified, the module starts with the iTunes reader

  2. It checks the first item and channel for iTunes-specific fields

  3. If no iTunes fields are found, it switches to the Media RSS reader

  4. Extension fields are only included in the output when actually present

Explicit Override:

iTunes Podcast Fields

When iTunes podcast extensions are detected, these additional fields are available:

Channel Level (in feedData.channel):

  • itunesAuthor - Podcast author

  • itunesSubtitle - Podcast subtitle

  • itunesSummary - Longer description

  • itunesImage - Artwork URL

  • itunesExplicit - Content rating (true/false)

  • itunesCategories - Array of category strings

  • itunesOwnerName - Owner name

  • itunesOwnerEmail - Owner email

Item Level (in each feedData.items[]):

  • itunesTitle - Episode title

  • itunesDuration - Duration (HH:MM:SS format)

  • itunesEpisode - Episode number

  • itunesSeason - Season number

  • itunesEpisodeType - Type (full, trailer, bonus)

  • itunesExplicit - Episode content rating

  • itunesAuthor - Episode author

  • itunesSummary - Episode summary

  • itunesSubtitle - Episode subtitle

  • itunesImage - Episode artwork URL

Media RSS Fields

When Media RSS extensions are detected, these additional fields are available:

Item Level (in each feedData.items[]):

  • mediaThumbnail - Struct with:

    • url - Thumbnail image URL

    • width - Image width in pixels

    • height - Image height in pixels

    • time - Time offset (for video thumbnails)

  • Additional Media RSS fields as available in the feed

🎯 Best Practices

Performance

  • Cache feed data - Cache parsed feeds to reduce HTTP requests

  • Use maxItems - Limit items when you don't need the full feed

  • Set reasonable timeouts - Default 60s is generous, adjust as needed

  • Handle failures gracefully - Feeds can be temporarily unavailable

  • Validate feed URLs - Check URLs before attempting to parse

Feed Creation

  • Include all required fields - title, link, description for channel and items

  • Use absolute URLs - Ensure all links are fully qualified URLs

  • Set proper dates - Use DateTime objects or valid date strings

  • Validate XML - Test generated feeds with validators

  • Use escapeChars - Enable when content contains HTML/special characters

  • Provide author info - Include author/creator information for items

iTunes Podcasts

  • Square artwork - iTunes requires 1400x1400 to 3000x3000 pixels

  • Set explicit flag - Always specify explicit/clean content rating

  • Include categories - Help users discover your podcast

  • Add episode metadata - Season, episode numbers, type (full/trailer/bonus)

  • Enclosure required - Each episode must have an audio enclosure

Security

  • Validate sources - Only read from trusted feed URLs

  • Sanitize output - Escape feed content when displaying in HTML

  • Set timeouts - Prevent long-running operations

  • Handle errors - Catch and log parsing failures

  • Use HTTPS - Prefer HTTPS URLs for feed sources

❓ Troubleshooting

Feed Reading Issues

Problem: Feed fails to parse or returns no items.

Solutions:

  • ✅ Verify the URL is accessible (try in browser)

  • ✅ Check if URL requires authentication

  • ✅ Increase timeout for slow-loading feeds

  • ✅ Verify feed is valid RSS/Atom (use feed validator)

  • ✅ Check for network/firewall issues

  • ✅ Review BoxLang logs for parsing errors

Extension Fields Not Appearing

Problem: iTunes or Media RSS fields are missing.

Solutions:

  • ✅ Verify the feed actually contains extension fields (view XML)

  • ✅ Check that extensions are in correct namespace

  • ✅ Try forcing reader: itunes="true" or mediaRss="true"

  • ✅ Inspect raw XML with xmlVar attribute

  • ✅ Validate feed with podcast/media RSS validators

Feed Creation Problems

Problem: Generated feed is invalid or won't display.

Solutions:

  • ✅ Validate feed XML with online validator (W3C, Podbase)

  • ✅ Ensure all required fields are present (title, link, description)

  • ✅ Use absolute URLs, not relative paths

  • ✅ Check date formats are valid DateTime objects

  • ✅ Enable escapeChars="true" if content has HTML

  • ✅ Verify enclosure URLs are accessible (for podcasts)

File Output Issues

Problem: Feed won't save to file.

Solutions:

  • ✅ Verify output directory exists and is writable

  • ✅ Check file permissions on the target path

  • ✅ Enable overwrite="true" to replace existing files

  • ✅ Use absolute file paths, not relative

  • ✅ Ensure sufficient disk space

🔗 Resources

Last updated

Was this helpful?