//----------------------------------SUB STRING FUNCTION----------------------------------------------
 function shorten_string($string, $wordsreturned)
/*  Returns the first $wordsreturned out of $string.  If string
	contains more words than $wordsreturned, the entire string
	is returned.*/
{
	$retval = $string;	//	Just in case of a problem
	$array = explode(" ", $string);
	/*  Already short enough, return the whole thing*/
	if (count($array)
	{
		$retval = $string;
	}
	/*  Need to chop of some words*/
	else
	{
		array_splice($array, $wordsreturned);
		$retval = implode(" ", $array)." ...";
	}
	return $retval;
}
 //-------------------------------------------------------------------------------
$booking_page = "pt/5-estrelas-hotel-luxury-florenca-italia/reserve";
  $doc = new DomDocument();
  $doc->load( 'http://feed.bookassist.com/feed/specials_xml.jsp?hotel_id=2367&guide_id=...' );
  	$specials = $doc->getElementsByTagName( "special" );
	foreach( $specials as $special ){
			$end_dates = $special->getElementsByTagName("end_date");
			$end_date  = $end_dates->item(0)->nodeValue;
			$special_froms = $special->getElementsByTagName("special_from");
			$special_from  = $special_froms->item(0)->nodeValue;
			$pgs = $special->getElementsByTagName("pg");
			$pg  = $pgs->item(0)->nodeValue;
			$booking_links = $special->getElementsByTagName("booking_link");
			$booking_link  = $booking_links->item(0)->nodeValue;
			$descriptions = $special->getElementsByTagName("description");
			$description  = $descriptions->item(0)->nodeValue;
			$new_desc = shorten_string($description, 4);
			$names = $special->getElementsByTagName("name");
			$name  = htmlspecialchars(strip_tags($names->item(0)->nodeValue), ENT_QUOTES );
			$images = $special->getElementsByTagName("image");
			$image  = $images->item(0)->nodeValue;
			$image_large = substr($image, 0, -5). "7.jpg";
			echo "
if($image_large != ""){
echo "
\n";
			}
			echo "
\n";
  			$packages = $special->getElementsByTagName( "pck_arr" );
			foreach( $packages as $package ){
				$pkg_names = $package->getElementsByTagName("pkg_name");
				$pkg_name  = $pkg_names->item(0)->nodeValue;
				//echo "$pkg_name
\n";
			}
echo "
\n";
}
?>

