Google Weather XML into PHP Page? -


i'm new php/xml , add google's xml weather info. , add info .php page.

i use url example: https://www.google.com/ig/api?weather=12601&hl=en&referrer=googlecalendar

the output @ url is:

<?xml version="1.0"?> <xml_api_reply version="1"> <weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" > <forecast_information> <city data="poughkeepsie, ny"/> <postal_code data="12601"/> <latitude_e6 data=""/> <longitude_e6 data=""/> <forecast_date data="2013-08-15"/> <current_date_time data="1970-01-01 00:00:00 +0000"/> <unit_system data="us"/> </forecast_information> <current_conditions> <condition data="partly cloudy"/> <temp_f data="78"/> <temp_c data="26"/> <humidity data="humidity: 44%"/> <icon data="/ig/images/weather/partly_cloudy.gif"/> <wind_condition data="wind: n @ 2 mph"/> </current_conditions> <forecast_conditions> <day_of_week data="thu"/> <low data="52"/> <high data="81"/> <icon data="/ig/images/weather/sunny.gif"/> <condition data="clear"/> </forecast_conditions> <forecast_conditions> <day_of_week data="fri"/> <low data="52"/> <high data="82"/> <icon data="/ig/images/weather/partly_cloudy.gif"/> <condition data="partly cloudy"/> </forecast_conditions> <forecast_conditions> <day_of_week data="sat"/> <low data="57"/> <high data="84"/> <icon data="/ig/images/weather/partly_cloudy.gif"/> <condition data="partly cloudy"/> </forecast_conditions> <forecast_conditions> <day_of_week data="sun"/> <low data="59"/> <high data="79"/> <icon data="/ig/images/weather/cloudy.gif"/> <condition data="cloudy"/> </forecast_conditions> </weather> </xml_api_reply> 

i extract following info. don't know how it, use min. amount of code if possible.

like display in .php page this:

currently: partly cloudy - 78* thu: clear - hi: 81* lo: 52* fri: partly cloudy - hi: 82* lo: 52* sat: partly cloudy - hi: 84* lo: 57* sun: cloudy - hi: 79* lo: 59* 

thanks.

use simplexml parse string , convert object.

$string = '...'; $xml = simplexml_load_string($string);  print_r($xml); 

demo: http://codepad.org/ig8puwbq


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -