Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
<?php $feed = simplexml_load_file("https://example.com/feed.rss"); // Handle XML namespaces in RSS 2.0 $feed->registerXPathNamespace("media", "http://search.yahoo.com/mrss/"); foreach ($feed->channel->item as $item) { $title = (string) $item->title; $link = (string) $item->link; $pubDate = (string) $item->pubDate; $desc = (string) $item->description; // Get media content (using namespace) $media = $item->children("media", true)->content; $image = (string) $media->attributes()->url; echo "<h2>{$title}</h2><p>{$desc}</p>"; }
Result
Open