Galera queria pegar os dados sobre previsão de tempo de um site http://www.webservicex.com/globalweather.asmx/GetWeather?CityName=Sao%20Paulo&CountryName=Brazil
O resultado no browser é o seguinte :
<string>
<?xml version="1.0" encoding="utf-16"?>
Sao Paulo/Congonhas Aeroporto, Brazil (SBSP) 23-37S 046-39W 802M
Jan 18, 2008 - 01:00 PM EST / 2008.01.18 1800 UTC
from the N (350 degrees) at 10 MPH (9 KT):0
greater than 7 mile(s):0
mostly cloudy
80 F (27 C)
69 F (21 C)
69%
29.91 in. Hg (1013 hPa)
Success
Eu estou obtendo ele com o seguinte código:
[code]
public static Document getDocument( DocumentBuilder db, String urlString ) {
try {
URL url = new URL( urlString );
try {
URLConnection URLconnection = url.openConnection( ) ;
HttpURLConnection httpConnection = (HttpURLConnection) URLconnection;
int responseCode = httpConnection.getResponseCode( ) ;
if ( responseCode == HttpURLConnection.HTTP_OK) {
InputStream in = httpConnection.getInputStream( ) ;
try {
Document doc = db.parse( in );
return doc;
} catch(org.xml.sax.SAXException e ) {
e.printStackTrace( ) ;
}
} else {
System.out.println( "HTTP connection response != HTTP_OK" );
}
} catch ( IOException e ) {
e.printStackTrace( ) ;
} // Catch
} catch ( MalformedURLException e ) {
e.printStackTrace( ) ;
} // Catch
return null;
} // getDocument
[/code]
e o que tenho de retorno não e no mesmo, ele vem de outra maneira…
Eu queria estar manipulando isso de modo que eu tivesse a saída assim
Sao Paulo/Congonhas Aeroporto, Brazil (SBSP) 23-37S 046-39W 802M
Jan 18, 2008 - 02:00 PM EST / 2008.01.18 1900 UTC
from the NNW (340 degrees) at 15 MPH (13 KT):0 Wind;
greater than 7 mile(s):0
mostly cloudy
78 F (26 C)
66 F (19 C)
65%
29.91 in. Hg (1013 hPa)
Ou talvez a questão seja como eu manipulo XML a partir de um URL http://www.webservicex.com/globalweather.asmx/GetWeather?CityName=Sao%20Paulo&CountryName=Brazil
Valeu