"); global $w; foreach ($attribs as $val){ switch ($name): case ($name == "EPOCH"): global $epoch; $epoch = $val; break; case ($name == "UPDATED"): global $updated; $updated = $val; break; case ($name == "AGEH"): global $ageh; $ageh = $val; break; case ($name == "AGEM"): global $agem; $agem = $val; break; case ($name == "AGES"): global $ages; $ages = $val; break; case ($name == "TYPE"): global $type; $type = $val; break; case ($name == "ID"): global $id; $id = $val; break; case ($name == "LAT"): global $lat; $lat = $val; break; case ($name == "LON"): global $lon; $lon = $val; break; case ($name == "ADM1"): global $city; $city = $val; break; case ($name == "ADM2"): global $state; $state = $val; break; case ($name == "COUNTRY"): global $country; $country = $val; break; case ($name == "NEIGHBORHOOD"): global $neighborhood; $neighborhood = $val; break; case ($name == "DATEUTC"): global $dateutc; $dateutc = $val; break; case ($name == "WINDDIR"): global $winddir; $winddir = $val; break; case ($name == "WINDSPEEDMPH"): global $windspeedmph; $windspeedmph = $val; break; case ($name == "WINDGUSTMPH"): global $windgustmph; $windgustmph = $val; break; case ($name == "HUMIDITY"): global $humidity; $humidity = $val; break; case ($name == "TEMPF"): global $tempf; $tempf = $val; break; case ($name == "RAININ"): global $rainin; $rainin = $val; break; case ($name == "DAILYRAININ"): global $dailyrainin; $dailyrainin = $val; break; case ($name == "BAROMIN"): global $baromin; $baromin = $val; break; case ($name == "DEWPTF"): global $dewptf; $dewptf = $val; break; case ($name == "WEATHER"): global $weather; $weather = $val; break; case ($name == "CLOUDS"): global $clouds; $clouds = $val; break; case ($name == "WINDCHILLF"): global $windchillf; $windchillf = $val; break; case ($name == "HEATINDEXF"): global $heatindexf; $heatindexf =$val; break; case ($name == "SOFTWARETYPE"): global $softwaretype; $softwaretype = $val; break; case ($name == "ELEV"): global $elev; $elev = $val; break; case ($name == "MAXTEMP"): global $maxtemp; $maxtemp = $val; break; case ($name == "MINTEMP"): global $mintemp; $mintemp = $val; break; case ($name == "MAXDEWPOINT"): global $maxdewpoint; $maxdewpoint = $val; break; case ($name == "MINDEWPOINT"): global $mindewpoint; $mindewpoint = $val; break; case ($name == "MAXPRESSURE"): global $maxpressure; $maxpressure = $val; break; case ($name == "MINPRESSURE"): global $minpressure; $minpressure = $val; break; case ($name == "MAXWINDSPEED"): global $maxwindspeed; $maxwindspeed = $val; break; case ($name == "MAXWINDGUST"): global $maxwindgust; $maxwindgust = $val; break; case ($name == "MAXRAIN"): global $maxrain; $maxrain = $val; break; case ($name == "MAXHEATINDEX"): global $maxheatindex; $maxheatindex = $val; break; case ($name == "MINWINDCHILL"): global $minwindchill; $minwindchill = $val; break; case ($name == "RTFREQ"): global $rtfreq; $rtfreq = $val; break; case ($name == "MORANS"): global $morans; $morans = $val; break; $w->cur_tag = $name; endswitch; unset($w); } } } // This does nothing here. function end_tag($parser, $name) { } // This setsup the element handler. xml_set_element_handler($xmlparser, "start_tag", "end_tag"); // This does nothing here. Needs to be there so $data gets parsed. function tag_contents($parser, $data) { } /* This if statement does two things. 1) it parses the document according to our functions created above. 2) If the parse fails for some reason it returns an */ error message and also tells us which line the error occurred at. xml_set_character_data_handler($xmlparser, "tag_contents"); if(!(xml_parse($xmlparser, $data))){ die("Error on line " . xml_get_current_line_number($xml_parser)); } // This frees the memory used by the parser. xml_parser_free($xmlparser); // This part converts wind direction from degrees to compass points. if ($winddir == "0") { $direction = "North"; } elseif ($winddir == "22") { $direction = "NNE"; } elseif ($winddir == "45") { $direction = "NorthEast"; } elseif ($winddir == "67") { $direction = "ENE"; } elseif ($winddir == "90") { $direction = "East"; } elseif ($winddir == "112") { $direction = "ESE"; } elseif ($winddir == "135") { $direction = "SouthEast"; } elseif ($winddir == "157") { $direction = "SSE"; } elseif ($winddir == "180") { $direction = "South"; } elseif ($winddir == "202") { $direction = "SSW"; } elseif ($winddir == "225") { $direction = "SouthWest"; } elseif ($winddir == "247") { $direction = "WSW"; } elseif ($winddir == "270") { $direction = "West"; } elseif ($winddir == "292") { $direction = "WNW"; } elseif ($winddir == "315") { $direction = "NorthWest"; } elseif ($winddir == "337") { $direction = "NNW"; } /* This part looks at wind chill, and if it says -999, convert to the temperature. Weather Underground calculates wind chill on the fly, and if the wind speed is to low, it will return "null", which translates to -999 in the data stream. We do not want to see -999, so we preform this test. */ if ($windchillf == "-999") { $windchillf = $tempf; } ?>