PHP RSS Parser Not Working
Posted: Wed Oct 06, 2010 2:05 pm
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;
}
?>