I have done a search for this but I haven't had any luck finding exactly what I am looking for. I am using simpleXML to parse a RSS feed I have made and it works great for showing just a single entry. I am trying to modify this method to just pull the most recent updated entry. How would I get it to update or just pull the most recent entry?
This is what I have now that parses the RSS feed and shows just one single entry but, this is where I am stuck as I would just like to show the most recent entry.
This is just a snippet of the most relevant code that parses the feed.
//Set initial output to false
$tData = false;
for($i = 0; $i < 1; $i++){
$location = $xml->reports[$i]->location;
$upperCase = strtoupper($location);
$report = $xml->reports[$i]->report;
$timestamp = $xml->reports[$i]->timestamp;
$updateTime = DATE("g:i A", STRTOTIME($timestamp));
// Set table style
$tableStyle = "width: 100%; margin:0px auto; background-color:{$bkgColor};";
$td1Style = "{$tbrdr};{$sbrdr}; text-align:center; font-size: 11px; background-image:url({$imagesDir}headerbgd2.gif); color:{$dtColor};";
$td2Style = "{$sbrdr}; text-align:center; font-size: 12px; padding: 1px 0px 1px 0px; background-color:{$bkgColor};";
$td3Style = "{$sbrdr}; {$bbrdr}; text-align:center; background-color:{$bc};";
// construct data for table display
$tData .= "<table style='{$tableStyle}' cellpadding='0' cellspacing='0'>\n";
$tData .= "<tbody>\n";
$tData .= " <tr><td style='{$td1Style}'>LATEST LOCAL STORM REPORT</td></tr>\n";
$tData .= " <tr><td style='{$td2Style}'><b>{$report}</b> - <span style='color: rgb(204, 102, 0);'>{$upperCase} - {$updateTime}</span></td></tr>\n";
$tData .= " <tr><td style='{$td3Style}'><a href='wxmesqLSR.php' title='Click to view the details'>Click here for details</a></td></tr>\n";
$tData .= "</tbody>\n";
$tData .= "</table>\n";
$tData .= $afterTable;
}
EDIT: Sample of the XML file
<?xml version="1.0"?>
<entrys>
<reports>
<timestamp>Thu, 11 Jul 2013 23:19:39 -0500</timestamp>
<name>Mesquite Weather</name>
<location>Mesquite</location>
<report>GENERAL</report>
<description>Official MW test</description>
</reports>
<reports>
<timestamp>Fri, 12 Jul 2013 00:44:39 -0500</timestamp>
<name>Mesquite Weather</name>
<location>Sunnyvale</location>
<report>DOWNED POWER LINES</report>
<description>Just an official MW test</description>
</reports>
</entrys>
-Thanks!