Here you are; basically it reads IDs from a table; searches an XML document, and updates the records in the table. I've removed most of the error checking to make it more readable for you.
<?php
include_once('wordpress/wp-config.php');
#include_once('wordpress/wp-load.php');
#include_once('wordpress/wp-includes/wp-db.php');
$results = $wpdb->get_results("select id,slug from travel_wp_affproducts WHERE id > 50");
$ProductList = array ();
$Slugs = array ();
foreach ($results as $id) {
array_push($ProductList, $id->id);
$Slugs[ $id->id ] = $id->slug;
}
$xml = simplexml_load_file('wordpress/i/data.wiggle');
foreach ($ProductList as $prodID) {
$result = $xml->xpath("//prod[@id='$prodID']");
if ( ! empty($result) ) {
$name = $xml->xpath("//prod[@id='$prodID']/text/name");
$url = $xml->xpath("//prod[@id='$prodID']/uri/awTrack");
$price = $xml->xpath("//prod[@id='$prodID']/price/buynow");
$db_insert = "INSERT INTO travel_wp_affproducts SET id='$prodID',\n";
$db_insert .= 'name="'. $name[0] .'", ';
$db_insert .= "url='$url[0]', ";
$db_insert .= "stamp=now(), ";
$db_insert .= "value='£".preg_replace('/\.00$/','',$price[0])."' \n";
$db_insert .= "ON DUPLICATE KEY UPDATE \n";
$db_insert .= 'name="'. $name[0] .'", ';
$db_insert .= "url='$url[0]', ";
$db_insert .= "stamp=now(), ";
$db_insert .= "value='£".preg_replace('/\.00$/','',$price[0])."'; \n";
$success = $wpdb->query($db_insert);
}