registerXPathNamespace('yweather', 'http://xml.weather.yahoo.com/ns/rss/1.0'); $location = $xml->channel->xpath('yweather:location'); if(!empty($location)){ foreach($xml->channel->item as $item){ $current = $item->xpath('yweather:condition'); $forecast = $item->xpath('yweather:forecast'); $current = $current[0]; $output = <<Weather for {$location[0]['city']}, {$location[0]['region']} {$current['date']}

Current Conditions

{$current['temp']}°F
  {$current['text']}

Forecast

{$forecast[0]['day']} - {$forecast[0]['text']}. High: {$forecast[0]['high']} Low: {$forecast[0]['low']}
{$forecast[1]['day']} - {$forecast[1]['text']}. High: {$forecast[1]['high']} Low: {$forecast[1]['low']}

END; } }else{ $output = '

No results found, please try a different zip code.

'; } ?> Weather