Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/07/2013, 18:10
marcolopez1
 
Fecha de Ingreso: julio-2013
Mensajes: 1
Antigüedad: 10 años, 10 meses
Puntos: 0
Pregunta Problema function.simplexml-load-file

Hola, buen día. Es la primera vez que hago un post. Los saludo a todos.

Resulta que desde hace tiempo he tratado de implementar el clima en mi web, pero ningun tipo de widget me convence. He encontrado este código que puesto en esta web me gusta [URL="http://creaelicita.cl/Clima/"]http://creaelicita.cl/Clima/[/URL], creo que puedo editar un poco para que sólo se vea el clima actual y no el de los próximos días.

Este es el código que utilizo:

Código PHP:
Ver original
  1. <?
  2. $xml = simplexml_load_file('http://weather.service.msn.com/data.aspx?weadegreetype=C&culture=es-ES&weasearchstr=Curacavi,CL');
  3. $information = $xml->xpath("weather");$information=(array)$information[0]->attributes();$information=$information['@attributes'];
  4. $current = $xml->xpath("weather/current");$current=(array)$current[0]->attributes();$current=$current['@attributes'];
  5. $forecast_list = $xml->xpath("weather/forecast");
  6. ?>
  7. <html>
  8.     <head>
  9.         <title>Pronóstico del Tiempo</title>
  10.     </head>
  11.     <body>
  12.         <h3>Curacaví, Santiago de Chile</h3>
  13.                 <h4>El Clima Ahora</h4>  
  14.                 <div class="weather"> <img src="<?= $information[imagerelativeurl].$current['skycode']?>.gif" alt="Clima"?>
  15.             <span class="condition">
  16.             <?= $current[temperature]?>°C,
  17.             <?=    $current[skytext]?>
  18.             </span>
  19.         </div>
  20.         <h4>Proximos Días</h4>
  21.         <?
  22.          foreach($forecast_list as $forecast){
  23.              $forecast=(array)$forecast[0]->attributes();$forecast=$forecast['@attributes'];
  24.           ?>
  25.         <div class="weather">
  26.             <img src="<?= $information[imagerelativeurl].$forecast['skycodeday']?>.gif" alt="Clima"?>
  27.             <div><? echo strtoupper(substr($forecast[day],0,1));echo substr($forecast[day],1);?></div>
  28.             <span class="condition">
  29.                 <?= $forecast[low]?>°C - <?= $forecast[high] ?>°C,
  30.                 <?= $forecast[skytextday]?>
  31.             </span>
  32.         </div>
  33. <? }?>

Pero al cargarlo en mi web me aparece sólo esto:

Warning: simplexml_load_file() [function.simplexml-load-file]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/laspinta/public_html/ejemplo.php on line 143

Warning: simplexml_load_file(http://weather.service.msn.com/data....tr=Curacavi,CL) [function.simplexml-load-file]: failed to open stream: no suitable wrapper could be found in /home/laspinta/public_html/ejemplo.php on line 143

Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://weather.service.msn.com/data.aspx?weadegreetype=C&culture=es-ES&weasearchstr=Curacavi,CL" in /home/laspinta/public_html/ejemplo.php on line 143

Fatal error: Call to a member function xpath() on a non-object in /home/laspinta/public_html/ejemplo.php on line 144


Si alguien pudiera orientarme en esto, debido a que jamas he estudiado algo por el estilo y realmente quiero que los usuarios de mi web sepan cómo está el clima.

Gracias.

P.D. Si hay algo mal en mi post les ruego no sean crueles, es la primera vez que hago esto.

Última edición por Triby; 02/07/2013 a las 18:47 Razón: Poner código en highlight