Jump to content

RSS XML Parsing Problems


raydowe

Recommended Posts

I'm hoping someone can help me with this.

 

I'm trying to convert an atom rss feed (http://muskokarunning.blogspot.com/atom.xml) to HTML using PHP. I've used several pre-made solutions, and written 2 of my own in an attempt to make it work. I'm more of a flash coder, and I can get it working fine with AS3, but for some reason everything I have tried with php ignores the first 3 posts? Can anyone see anything wrong with my code or the xml feed?

 

Thanks in advance for your help.

 

function blogparse($file)
{
if(!$xml=simplexml_load_file($file))
{
	trigger_error('Error reading XML file',E_USER_ERROR);
}

$finalstring = '';

$channel = $xml->channel;

$items = $channel->item;

foreach($items as $item)
{	
	$name = $item->getName();

	if($name = 'item')
	{
		$finalstring .= '<a href="'. $item->link . '">';
		$finalstring .= '<h1>' . $item->title . '</h1></a>';
		$finalstring .= '<p>' . $item->description . '</p>';
	}
}
  return($finalstring);

  echo(blogparse('http://muskokarunning.blogspot.com/atom.xml'));
}

 

 

Link to comment
https://forums.phpfreaks.com/topic/124310-rss-xml-parsing-problems/
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.