igmolicious Posted July 2, 2008 Share Posted July 2, 2008 I'm new here, so please forgive me if I offend any traditions, or anything. Anyhow, I'm trying to pull some news releases from RSS feeds, and meeting with some very limited success, as well as some strange problems. Here's the code that I'm using (more description of the problem(s) afterwards): <?php try { $doc = new DOMDocument(); $doc->load('http://feeds.feedburner.com/CityOfVillains-CommunitySite.xml'); //$doc->load('http://cohvault.ign.com/show_rss.php'); //$doc->load('http://www.cityofvillains.com/news/index.rdf'); $maxDisplay = 5; $numArticles = 0; $items = $doc->getElementsByTagName("item"); foreach( $items as $item ) { if($numArticles == $maxDisplay) { break; } $titles = $item->getElementsByTagName("title"); $title = $titles->item(0)->nodeValue; $descriptions = $item->getElementsByTagName("description"); $description = $descriptions->item(0)->nodeValue; $links = $item->getElementsByTagName("link"); $link = $links->item(0)->nodeValue; echo "<a class='content' href='$link' target='_blank'>$title</a>\n<br>$description<br>\n<br>\n"; $numArticles++; } } catch(Exception $err) { print $err->getMessage(); } ?> The code works fine for the cohvault.ign.com RSS feed, but the stream connection times out on the www.cityofvillains.com feed, and it gets a 404 on the feed.feedburner.com feed. All 3 of these work fine, however, when browsed to. Am I missing something completely obvious? Quote Link to comment https://forums.phpfreaks.com/topic/112951-strange-problem-using-domdocument/ Share on other sites More sharing options...
DeanWhitehouse Posted July 2, 2008 Share Posted July 2, 2008 404 means page missing, therefore the link is wrong. Quote Link to comment https://forums.phpfreaks.com/topic/112951-strange-problem-using-domdocument/#findComment-580209 Share on other sites More sharing options...
igmolicious Posted July 2, 2008 Author Share Posted July 2, 2008 404 means page missing, therefore the link is wrong. I understand, however, browsing the exact same link, copied and pasted from the code, does not result in a 404 error. Quote Link to comment https://forums.phpfreaks.com/topic/112951-strange-problem-using-domdocument/#findComment-580214 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.