Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <h3>Recent Topics</h3>
- <?php
- //Set new DOMDocument and load the RSS feed with it.
- $doc = new DOMDocument();
- $doc->load('http://gumclan.org?action=.xml;type=rss');
- //Set count variable to limit amount of items shown with RSS
- $i = 0;
- //For each <item> in the RSS feed:
- foreach($doc->getElementsByTagName('item') as $docItem)
- {
- //Fill up an array with all of the written tags
- $docArray = array(
- 'title' => $docItem->getElementsByTagName('title')->item(0)->nodeValue,
- 'link' => $docItem->getElementsByTagName('link')->item(0)->nodeValue,
- 'category' => $docItem->getElementsByTagName('category')->item(0)->nodeValue,
- 'pubDate' => $docItem->getElementsByTagName('pubDate')->item(0)->nodeValue
- );
- //Display the information in chosen format
- echo('Title: ' . $docArray['title'] . '<br />
- Category: ' . $docArray['category'] . '<br />
- Link: <a href="' . $docArray['link'] . '">' . $docArray['title'] . '</a><br />
- Publish date: ' . $docArray['pubDate'] . '<br /><br />');
- //Increment $i
- $i++;
- //If $i passes >2, stop the loop. This will stop it at 3 items
- if ($i > 2) {break;}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement