Skip to content

Instantly share code, notes, and snippets.

@paulmsmith
Created July 31, 2017 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulmsmith/862ffe0ed714705aa10bc114567b5ded to your computer and use it in GitHub Desktop.
Save paulmsmith/862ffe0ed714705aa10bc114567b5ded to your computer and use it in GitHub Desktop.
RSS Feed consume PHP
<?php
$xml_feed = new DOMDocument();
$xml_feed->load('http://public.sheltermanager.com/animals/gw1124/rss.xml');
$feed_items = array();
foreach ($xml_feed->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,
);
array_push($feed_items, $item);
}
foreach ($feed_items as $feed_item) { ?>
<div>
<a href="<?php echo $feed_item["link"] ?>">
<h4><?php echo $feed_item["title"] ?></h4>
</a>
<p><?php echo $feed_item["desc"] ?></p>
</div>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment