De momento logro capturar el XML que me envía weather.com, el cual tiene la siguiente estructura:
Código:
Éste archivo lo intento parsear con mi PHP que consta de las siguientes líneas:<?xml version="1.0" encoding="ISO-8859-1"?> <!-- This document is intended only for use by authorized licensees of The --> <!-- Weather Channel. Unauthorized use is prohibited. Copyright 1995-2010, --> <!-- The Weather Channel Interactive, Inc. All Rights Reserved. --> <weather ver="2.0"> <head> <locale>en_US</locale> <form>MEDIUM</form> <ut>C</ut> <ud>km</ud> <us>km/h</us> <up>mb</up> <ur>mm</ur> </head> <loc id="ARBA0004"> <dnam>Bahia Blanca, Argentina</dnam> <tm>4:34 PM</tm> <lat>-38.72</lat> <lon>-62.28</lon> <sunr>7:15 AM</sunr> <suns>7:16 PM</suns> <zone>-3</zone> </loc> <cc> <lsup>3/23/10 3:00 PM Local Time</lsup> <obst>Bahia Blanca, ARGENTINA</obst> <tmp>26</tmp> <flik>25</flik> <t>Sandstorm and Windy</t> <icon>19</icon> <bar> <r>995.6</r> <d>N/A</d> </bar> <wind> <s>40</s> <gust>N/A</gust> <d>250</d> <t>WSW</t> </wind> <hmid>32</hmid> <vis>15.0</vis> <uv> <i>5</i> <t>Moderate</t> </uv> <dewp>8</dewp> <moon> <icon>7</icon> <t>First Quarter</t> </moon> </cc> <dayf> <lsup>3/23/10 2:15 PM Local Time</lsup> <day d="0" t="Tuesday" dt="Mar 23"> <hi>N/A</hi> <low>12</low> <sunr>7:15 AM</sunr> <suns>7:16 PM</suns> <part p="d"> <icon>44</icon> <t>N/A</t> <wind> <s>N/A</s> <gust>N/A</gust> <d>N/A</d> <t>N/A</t> </wind> <bt>N/A</bt> <ppcp>10</ppcp> <hmid>N/A</hmid> </part> <part p="n"> <icon>33</icon> <t>Mostly Clear</t> <wind> <s>24</s> <gust>N/A</gust> <d>119</d> <t>ESE</t> </wind> <bt>M Clear</bt> <ppcp>10</ppcp> <hmid>77</hmid> </part> </day> <day d="1" t="Wednesday" dt="Mar 24"> <hi>26</hi> <low>15</low> <sunr>7:16 AM</sunr> <suns>7:14 PM</suns> <part p="d"> <icon>32</icon> <t>Sunny</t> <wind> <s>24</s> <gust>N/A</gust> <d>26</d> <t>NNE</t> </wind> <bt>Sunny</bt> <ppcp>0</ppcp> <hmid>63</hmid> </part> <part p="n"> <icon>31</icon> <t>Clear</t> <wind> <s>24</s> <gust>N/A</gust> <d>12</d> <t>NNE</t> </wind> <bt>Clear</bt> <ppcp>0</ppcp> <hmid>79</hmid> </part> </day> <day d="2" t="Thursday" dt="Mar 25"> <hi>27</hi> <low>17</low> <sunr>7:17 AM</sunr> <suns>7:13 PM</suns> <part p="d"> <icon>32</icon> <t>Sunny</t> <wind> <s>31</s> <gust>N/A</gust> <d>348</d> <t>NNW</t> </wind> <bt>Sunny</bt> <ppcp>0</ppcp> <hmid>65</hmid> </part> <part p="n"> <icon>29</icon> <t>Partly Cloudy</t> <wind> <s>19</s> <gust>N/A</gust> <d>356</d> <t>N</t> </wind> <bt>P Cloudy</bt> <ppcp>0</ppcp> <hmid>82</hmid> </part> </day> <day d="3" t="Friday" dt="Mar 26"> <hi>28</hi> <low>17</low> <sunr>7:18 AM</sunr> <suns>7:11 PM</suns> <part p="d"> <icon>32</icon> <t>Sunny</t> <wind> <s>24</s> <gust>N/A</gust> <d>333</d> <t>NNW</t> </wind> <bt>Sunny</bt> <ppcp>0</ppcp> <hmid>74</hmid> </part> <part p="n"> <icon>29</icon> <t>Partly Cloudy</t> <wind> <s>18</s> <gust>N/A</gust> <d>337</d> <t>NNW</t> </wind> <bt>P Cloudy</bt> <ppcp>10</ppcp> <hmid>91</hmid> </part> </day> <day d="4" t="Saturday" dt="Mar 27"> <hi>28</hi> <low>16</low> <sunr>7:19 AM</sunr> <suns>7:10 PM</suns> <part p="d"> <icon>30</icon> <t>Partly Cloudy</t> <wind> <s>18</s> <gust>N/A</gust> <d>302</d> <t>WNW</t> </wind> <bt>P Cloudy</bt> <ppcp>20</ppcp> <hmid>83</hmid> </part> <part p="n"> <icon>29</icon> <t>Partly Cloudy</t> <wind> <s>14</s> <gust>N/A</gust> <d>340</d> <t>NNW</t> </wind> <bt>P Cloudy</bt> <ppcp>10</ppcp> <hmid>99</hmid> </part> </day> </dayf> </weather>
Código PHP:
<?php
/*echo $_GET['var1'];*/
$weatherDefaultLocationID = 'ARBA0004';
$weatherDayForecast = '10';
$weatherPartnerID ='10599XXXXX';
$weatherPassword ='e28a51XXXXXXXXX';
$weatherUnits = 'm';
/*http://xoap.weather.com/weather/local/ARBA0004?cc=*&dayf=10&unit=m&par=1059901650&key=e28a512bd577b41f*/
$weather_url = "http://xoap.weather.com/weather/local/".$weatherDefaultLocationID."?cc=*&dayf=".$weatherDayForecast."&unit=".$weatherUnits."&par=".$weatherPartnerID."&key=".$weatherPassword."";
$rss = simplexml_load_file($weather_url);
/*echo '<pre>';
print_r($success);
echo '</pre>'; */
$temperatura = $rss->weather->cc->tmp;
echo $temperatura;
?>
Gracias !!!