parse an rss feed and update/insert/delete rows

z4wanted

New Member
I'm trying to parse multiple RSS feeds and If they change, thus update my records in my MySQL table.Currently, I have a script that inserts items of RSS Feeds (just post in the url in a form and submit). This inserts the following into my table:title, rss_url, description, price, discount, totalThis all works perfectly well.The next part is a script that updates the rows if they change in the RSS, but the only changes are if the price or discount update. This also works greatWhat I'm also looking to do is:If an item in the RSS feed is removed, then my script needs to detect this and delete the row or insert a flag into my table to say its been deleted...My code is quite long winded:\[code\]$result = mysql_query("SELECT * from easy_contents");while($row = mysql_fetch_array($result)){$articles = array();$easy_url = $row['rss_url'];$rawFeed = file_get_contents($easy_url);$xml = new SimpleXmlElement($rawFeed);$channel = array();$channel['title'] = $xml->channel->title;$channel['link'] = $xml->channel->link;$channel['description'] = $xml->channel->description;foreach ($xml->channel->item as $item){$article = array();$article['title'] = $item->title;$article['link'] = $item->link;$article['description'] = (string) trim($item->description);//strip out all the HTML tags$item->description = str_replace('<table><tr><td width="110">','', $item->description);$item->description = str_replace('</table>','', $item->description);$item->description = str_replace('</td>','', $item->description);$item->description = str_replace('<td>','', $item->description);$item->description = str_replace('<br />','', $item->description);$item->description = str_replace('<b>','', $item->description);$item->description = str_replace('</b>','', $item->description);$item->description = str_replace('</tr>','', $item->description);//find all url encoded
 
Back
Top