Mam następujący plik XML:
This XML file does not appear to have any style information associated with it. The document tree is shown below. <weatherdata> <location> <name>Bedford</name> <type/> <country>GB</country> <timezone/> <location altitude="0" latitude="52.13459" longitude="-0.46632" geobase="geonames" geobaseid="0"/> </location> <credit/> <meta> <lastupdate/> <calctime>0.0627</calctime> <nextupdate/> </meta> <sun rise="2014-05-29T03:49:01" set="2014-05-29T20:09:37"/> <forecast> <time day="2014-05-29"> <symbol number="803" name="broken clouds" var="04d"/> <precipitation/> <windDirection deg="91" code="E" name="East"/> <windSpeed mps="4.26" name="Gentle Breeze"/> <temperature day="18.57" min="14.5" max="19.22" night="14.5" eve="18.68" morn="18.57"/> <pressure unit="hPa" value="1019.32"/> <humidity value="97" unit="%"/> <clouds value="broken clouds" all="80" unit="%"/> </time> <time day="2014-05-30"> <symbol number="803" name="broken clouds" var="04d"/> <precipitation/> <windDirection deg="76" code="ENE" name="East-northeast"/> <windSpeed mps="4.32" name="Gentle Breeze"/> <temperature day="17.94" min="12.47" max="18.4" night="12.47" eve="17.58" morn="13.08"/> <pressure unit="hPa" value="1027.45"/> <humidity value="90" unit="%"/> <clouds value="broken clouds" all="56" unit="%"/> </time> <time day="2014-05-31"> <symbol number="802" name="scattered clouds" var="03d"/> <precipitation/> <windDirection deg="310" code="NW" name="Northwest"/> <windSpeed mps="2.21" name="Light breeze"/> <temperature day="17.28" min="11.48" max="18.91" night="11.48" eve="17.92" morn="12.28"/> <pressure unit="hPa" value="1029.33"/> <humidity value="94" unit="%"/> <clouds value="scattered clouds" all="36" unit="%"/> </time> <time day="2014-06-01"> <symbol number="801" name="few clouds" var="02d"/> <precipitation/> <windDirection deg="43" code="NE" name="NorthEast"/> <windSpeed mps="2.06" name="Light breeze"/> <temperature day="18.47" min="12.99" max="19.21" night="14.57" eve="18.86" morn="12.99"/> <pressure unit="hPa" value="1027.11"/> <humidity value="95" unit="%"/> <clouds value="few clouds" all="20" unit="%"/> </time> <time day="2014-06-02"> <symbol number="501" name="moderate rain" var="10d"/> <precipitation value="3.5" type="rain"/> <windDirection deg="183" code="S" name="South"/> <windSpeed mps="2.66" name="Light breeze"/> <temperature day="14.89" min="12.72" max="16.22" night="12.72" eve="16.21" morn="13.73"/> <pressure unit="hPa" value="1022.79"/> <humidity value="94" unit="%"/> <clouds value="overcast clouds" all="92" unit="%"/> </time> <time day="2014-06-03"> <symbol number="500" name="light rain" var="10d"/> <precipitation value="0.87" type="rain"/> <windDirection deg="48" code="NE" name="NorthEast"/> <windSpeed mps="4.74" name="Gentle Breeze"/> <temperature day="17.53" min="11.04" max="17.59" night="11.04" eve="17.59" morn="13.49"/> <pressure unit="hPa" value="1019.6"/> <humidity value="0" unit="%"/> <clouds value="few clouds" all="12" unit="%"/> </time> <time day="2014-06-04"> <symbol number="500" name="light rain" var="10d"/> <precipitation value="0.5" type="rain"/> <windDirection deg="359" code="" name=""/> <windSpeed mps="3.72" name="Gentle Breeze"/> <temperature day="17.59" min="10.99" max="17.72" night="10.99" eve="17.72" morn="12.78"/> <pressure unit="hPa" value="1014.63"/> <humidity value="0" unit="%"/> <clouds value="broken clouds" all="63" unit="%"/> </time> </forecast> </weatherdata>
Chciałbym pobrać informacje o pogodzie na dzisiaj oraz kolejne dni. Na dzisiaj pobieram następującym kodem:
$map_url = ('http://www.serwer.pl/plik.xml'); $xml_load = simplexml_load_file($map_url); $tmp = $xml_load->forecast->time->symbol->attributes(); $opis1 = $tmp['name']; // opis pogody $obrazek1 = $tmp['var']; // kod obrazka $tmp = $xml_load->forecast->time->windDirection->attributes(); $kierunek_wiatru = $tmp['code']; $kierunek_wiatru1 = $tmp['deg'].$kierunek_wiatru; // kierunek wiatru $tmp = $xml_load->forecast->time->windSpeed->attributes(); $szybkosc_wiatru1 = $tmp['mps']." mps"; // szybkość wiatru $tmp = $xml_load->forecast->time->temperature->attributes(); $temperatura1 = $tmp['day']."º"." C"; // temperatura $temperatura_min1 = $tmp['min']."º"." C"; // temperatura minimalna $temperatura_max1 = $tmp['max']."º"." C"; // temperatura maksymalna
W jaki sposób mogę pobrać na jutro/pojutrze itp?
bardzo proszę o pomoc,
Northwest