Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2012
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <h3>Recent Topics</h3>
  2. <?php
  3.  
  4. //Set new DOMDocument and load the RSS feed with it.
  5. $doc = new DOMDocument();
  6. $doc->load('http://gumclan.org?action=.xml;type=rss');
  7.  
  8. //Set count variable to limit amount of items shown with RSS
  9. $i = 0;
  10.  
  11. //For each <item> in the RSS feed:
  12. foreach($doc->getElementsByTagName('item') as $docItem)
  13. {
  14. //Fill up an array with all of the written tags
  15. $docArray = array(
  16. 'title' => $docItem->getElementsByTagName('title')->item(0)->nodeValue,
  17. 'link' => $docItem->getElementsByTagName('link')->item(0)->nodeValue,
  18. 'category' => $docItem->getElementsByTagName('category')->item(0)->nodeValue,
  19. 'pubDate' => $docItem->getElementsByTagName('pubDate')->item(0)->nodeValue
  20. );
  21.  
  22. //Display the information in chosen format
  23. echo('Title: ' . $docArray['title'] . '<br />
  24. &nbsp; Category: ' . $docArray['category'] . '<br />
  25. &nbsp;&nbsp; Link: <a href="' . $docArray['link'] . '">' . $docArray['title'] . '</a><br />
  26. Publish date: ' . $docArray['pubDate'] . '<br /><br />');
  27.  
  28. //Increment $i
  29. $i++;
  30.  
  31. //If $i passes >2, stop the loop. This will stop it at 3 items
  32. if ($i > 2) {break;}
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement