PHP RSS Parser Not Working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
walker6o9
Forum Newbie
Posts: 5
Joined: Wed Jul 30, 2008 2:01 pm

PHP RSS Parser Not Working

Post by walker6o9 »

I'm trying to parse a feed and display the titles as links. I can grab the feed, and I can print the whole array of the feed, but for some reason, I can't seem to parse it out. I think my code is fine, the feed is broken up into items that have titles, what am I missing here?

Code: Select all

<?php

# INSTANTIATE CURL.
$curl = curl_init();

# CURL SETTINGS.
curl_setopt($curl, CURLOPT_URL, "http://feeds.feedburner.com/BrainRules");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);

# GRAB THE XML FILE.
$xmlTwitter = curl_exec($curl);

curl_close($curl);

# SET UP XML OBJECT.
$xmlObjTwitter = simplexml_load_string( $xmlTwitter );
//echo $xmlObjTwitter;
//print_r($xmlObjTwitter);

//print_r($xmlObjTwitter->title);
//print_r($xmlObjTwitter[0]);


$tempCounter = 0;
foreach ( $xmlObjTwitter -> item as $item )
{       
		echo 'loop';
    # DISPLAY ONLY 10 ITEMS.
    if ( $tempCounter < 3 )
    {
        echo "<li><a href=\"{$item -> guid}\">{$item -> title}</a></li>
";
    }

    $tempCounter += 1;
}
?>
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: PHP RSS Parser Not Working

Post by Jonah Bron »

I haven't looked at the code, but what doesn't work? Do you get errors? Do you have error reporting on?
Post Reply