tomgould/rsstojson

Universal RSS/Atom/XML parser that outputs clean JSON-compatible arrays.

Installs: 230

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/tomgould/rsstojson

v2.0.1 2025-11-17 12:36 UTC

This package is auto-updated.

Last update: 2025-12-17 13:16:53 UTC


README

RSStoJSON is a PHP library that parses RSS, Atom, or generic XML feeds (including MRSS video feeds) into structured, JSON-compatible arrays. It works with remote URLs or local files and is designed to be framework-agnostic.

๐Ÿš€ Features

  • Supports RSS, Atom, MRSS (Media RSS), and XML feeds
  • Works with local file paths or remote URLs
  • Handles namespaced elements and attributes (e.g., media:content, media:thumbnail)
  • JSON-encoding ready output
  • Includes CLI tool for terminal use
  • PHP 7.4+ compatible (works with Drupal 8, 9, 10, 11, and other modern PHP frameworks)
  • Composer-ready for easy installation

๐Ÿ“ฆ Installation

Via Composer:

composer require tomgould/rsstojson

๐Ÿ›  Usage

Programmatic

<?php

require 'vendor/autoload.php';

use TomGould\RSSToJson\RSSToJson;

$parser = new RSSToJson();
$feed = $parser->parse('https://example.com/feed.xml');
echo json_encode($feed, JSON_PRETTY_PRINT);

Parse Local Files

<?php

require 'vendor/autoload.php';

use TomGould\RSSToJson\RSSToJson;

$parser = new RSSToJson();
$feed = $parser->parse('/path/to/local/feed.xml');
echo json_encode($feed, JSON_PRETTY_PRINT);

CLI

After installing via composer, you can use the CLI tool:

vendor/bin/rsstojson https://example.com/feed.xml

Or if installed globally:

rsstojson https://example.com/feed.xml

๐Ÿ“ Examples

See the /examples directory for sample code:

  • examples/parse-url.php - Parse a remote feed
  • examples/parse-local.php - Parse a local MRSS video feed

๐Ÿงช Testing

Run the test suite:

composer test

Or using PHPUnit directly:

vendor/bin/phpunit tests

๐ŸŽฅ MRSS Support

This library fully supports Media RSS (MRSS) feeds, commonly used for video content. It properly handles namespaced elements like:

  • media:content - Video URLs and metadata
  • media:thumbnail - Video thumbnail images
  • media:category - Content categories
  • media:keywords - Content tags

See tests/sample-mrss.xml for an example MRSS feed structure.

๐Ÿ”ง Requirements

  • PHP 7.4 or higher
  • ext-libxml
  • ext-curl

๐Ÿชช License

MIT โ€” free for commercial and personal use.

๐Ÿค Contributing

Issues and pull requests are welcome on the GitHub repository.