PHP5 to display your City’s weather from an XML feed
I am sure we all pay attention to the weather -TV weather men are just obsessed with it.
When it come to web sites, some do display and some do not need to display the weather conditions. The National Weather Service provides weather XML feeds for over 1,800 locations around the country. I wanted to write a small script to display weather conditions on my web site using PHP5 xml parser.
This was the easiest code I have ever written.
—————————–
<?php
$rss = simplexml_load_file(’http://www.nws.noaa.gov/data
$weather = $rss->weather;
$temp = $rss->temp_f;
?>
<html xml:lang=”en” lang=”en”>
<head>
<title>weather</title>
</head>
<body>
<?php
echo $weather . “<br />”;
echo $temp . “<br />”;
?>
</body>
</html>
——————————
You can access any information in the XML feed and display it on your site. I accessed weather condition and temperature. You can see it on the top section of the left nav for Salt Lake City. Pick your own city -code out.

