Jump to content

Strange problem using DOMDocument


igmolicious

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/112951-strange-problem-using-domdocument/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.