raw XML weather data from NWS

Source code


<?php include('./.config.php') ;
$XML = <<<__XML__

<current_observation>
<credit>NOAA's National Weather Service</credit>
<credit_URL>http://weather.gov/</credit_URL>
<image>
<url>http://weather.gov/images/xml_logo.gif</url>
<title>NOAA's National Weather Service</title>
10 <link>http://weather.gov</link>
11 </image>
12 <suggested_pickup>15 minutes after the hour</suggested_pickup>
13 <suggested_pickup_period>60</suggested_pickup_period>
14 <location>Newark International Airport, NJ</location>
15 <station_id>KEWR</station_id>
16 <latitude>40.40.57N</latitude>
17 <longitude>074.10.10W</longitude>
18 <elevation>NA</elevation>
19 <observation_time>Last Updated on Apr 24, 6:51 pm EDT</observation_time>
20 <weather>Mostly Cloudy</weather>
21 <temperature_string>52 F (11 C)</temperature_string>
22 <temp_f>52</temp_f>
23 <temp_c>11</temp_c>
24 <relative_humidity>43</relative_humidity>
25 <wind_string>From the Southwest at 10 MPH</wind_string>
26 <wind_dir>Southwest</wind_dir>
27 <wind_degrees>230</wind_degrees>
28 <wind_mph>10.35</wind_mph>
29 <wind_gust_mph>0</wind_gust_mph>
30 <pressure_string>29.42" (996.2 mb)</pressure_string>
31 <pressure_mb>996.2</pressure_mb>
32 <pressure_in>29.42</pressure_in>
33 <dewpoint_string>30 F (-1 C)</dewpoint_string>
34 <dewpoint_f>30</dewpoint_f>
35 <dewpoint_c>-1</dewpoint_c>
36 <heat_index_string>Not Applicable</heat_index_string>
37 <heat_index_f>Not Applicable</heat_index_f>
38 <heat_index_c>Not Applicable</heat_index_c>
39 <windchill_string>48 F (9 C)</windchill_string>
40 <windchill_f>48</windchill_f>
41 <windchill_c>9</windchill_c>
42 <visibility>10.00 mi.</visibility>
43 <two_day_history_url>http://www.weather.gov/data/obhistory/KEWR.html</two_day_history_url>
44 <ob_url>http://www.nws.noaa.gov/data/METAR/KEWR.1.txt</ob_url>
45 <disclaimer_url>http://weather.gov/disclaimer.html</disclaimer_url>
46 <copyright_url>http://weather.gov/disclaimer.html</copyright_url>
47 <privacy_policy_url>http://weather.gov/notice.html</privacy_policy_url>
48 </current_observation>
49 
__XML__;
50 
highlight_string($XML);
51 echo 
'<br /><br />';
52 include(
'./.footer.php')?>

Output


<current_observation>
<credit>NOAA's National Weather Service</credit>
<credit_URL>http://weather.gov/</credit_URL>
<image>
<url>http://weather.gov/images/xml_logo.gif</url>
<title>NOAA's National Weather Service</title>
<link>http://weather.gov</link>
</image>
<suggested_pickup>15 minutes after the hour</suggested_pickup>
<suggested_pickup_period>60</suggested_pickup_period>
<location>Newark International Airport, NJ</location>
<station_id>KEWR</station_id>
<latitude>40.40.57N</latitude>
<longitude>074.10.10W</longitude>
<elevation>NA</elevation>
<observation_time>Last Updated on Apr 24, 6:51 pm EDT</observation_time>
<weather>Mostly Cloudy</weather>
<temperature_string>52 F (11 C)</temperature_string>
<temp_f>52</temp_f>
<temp_c>11</temp_c>
<relative_humidity>43</relative_humidity>
<wind_string>From the Southwest at 10 MPH</wind_string>
<wind_dir>Southwest</wind_dir>
<wind_degrees>230</wind_degrees>
<wind_mph>10.35</wind_mph>
<wind_gust_mph>0</wind_gust_mph>
<pressure_string>29.42" (996.2 mb)</pressure_string>
<pressure_mb>996.2</pressure_mb>
<pressure_in>29.42</pressure_in>
<dewpoint_string>30 F (-1 C)</dewpoint_string>
<dewpoint_f>30</dewpoint_f>
<dewpoint_c>-1</dewpoint_c>
<heat_index_string>Not Applicable</heat_index_string>
<heat_index_f>Not Applicable</heat_index_f>
<heat_index_c>Not Applicable</heat_index_c>
<windchill_string>48 F (9 C)</windchill_string>
<windchill_f>48</windchill_f>
<windchill_c>9</windchill_c>
<visibility>10.00 mi.</visibility>
<two_day_history_url>http://www.weather.gov/data/obhistory/KEWR.html</two_day_history_url>
<ob_url>http://www.nws.noaa.gov/data/METAR/KEWR.1.txt</ob_url>
<disclaimer_url>http://weather.gov/disclaimer.html</disclaimer_url>
<copyright_url>http://weather.gov/disclaimer.html</copyright_url>
<privacy_policy_url>http://weather.gov/notice.html</privacy_policy_url>
</current_observation>


previous: caching/parsing XML with DOM
next: SAX-parsing XML weather data


Last update 24-Apr-2005 5:23 pm | up | list examples | home