Created
July 31, 2017 14:49
-
-
Save paulmsmith/862ffe0ed714705aa10bc114567b5ded to your computer and use it in GitHub Desktop.
RSS Feed consume PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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