Displaying RSS Feeds with PHP
From Jay's Cafe' Wiki
<?php // SELA Buoy Aggregate RSS Feed function display_buoy_feed($rss_link,$rss_limit) { $rss = new DOMDocument(); $rss->load($rss_link); $feed = array(); foreach ($rss->getElementsByTagName('item') as $node) { $item = array ( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue, 'webMaster' => $node->getElementsByTagName('webMaster')->item(0)->nodeValue, ); array_push($feed, $item); } $limit = $rss_limit; for($x=0;$x<$limit;$x++) { $title = str_replace(' & ', ' & ', $feed[$x]['title']); $link = $feed[$x]['link']; $description = $feed[$x]['desc']; $date = date('l F d, Y', strtotime($feed[$x]['date'])); echo '<p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br />'; echo '<small><em>Posted on '.$date.'</em></small></p>'; echo '<p>'.$description.'</p>'; } } ?> <table class='rss-aggregate'> <tr> <td><?php display_buoy_feed('https://www.ndbc.noaa.gov/data/latest_obs/einl1.rss','1'); ?></td> <td><?php display_buoy_feed('https://www.ndbc.noaa.gov/data/latest_obs/kscf.rss','1'); ?></td> </tr> </table>