Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/12/2014, 16:19
trosh8
 
Fecha de Ingreso: febrero-2012
Mensajes: 11
Antigüedad: 12 años, 3 meses
Puntos: 0
Obtener datos de un Web Service

Hola buenas tardes,
Tengo un sitio donde quiero poner la temperatura y la hora de una ciudad de México, ya encontré el web service de donde puedo traer esa información.

[URL="http://www.webservicex.net/globalweather.asmx/GetWeather?CityName=Ixtapa-Zihuatanejo&CountryName=Mexico"]http://www.webservicex.net/globalweather.asmx/GetWeather?CityName=Ixtapa-Zihuatanejo&CountryName=Mexico[/URL]

Tengo ya este cliente:
<?php

try {
$client = new SoapClient("http://www.webservicex.net/globalweather.asmx?WSDL",
array('cache_wsdl' => WSDL_CACHE_NONE,'trace' => TRUE));
$param = array(
'CityName' => 'Ixtapa-Zihuatanejo',
'CountryName' => 'Mexico'
);

$ready = $client->GetWeather($param)->buscardsResult;
//var_dump($ready); //Verificar si hay resultado

$xml = simplexml_load_string($ready->any);

//Leer una fila de un DataSet.Name = "NewDataSet" que contiene
//un DataSet.Tables[0].Name = "Table"
$row1 = $xml->NewDataSet->Table;

$valueColRow = $xml->NewDataSet->Table->direccion;

var_dump($row1);
print_r($valueColRow);

} catch (Exception $e) {
trigger_error($e->getMessage(), E_USER_WARNING);
}
?>

Solo quiero recuperar el contenido de los tags de <Time> y el de <Temperature> alguien puede darme un poco de idea de como hacerlo?


Gracias por su ayuda.
DSM

Última edición por trosh8; 12/12/2014 a las 16:34