0
我有下面的代碼,它從我的結果中得到一個字符串,但我試圖找到一種方式,只顯示我的xml服務的字符串的值,但我不能,如何僅顯示該值?在te代碼中,您只能看到Web服務的conexion,是否需要解析xml字符串?我怎麼能只顯示從Web服務的價值xml
--xml
<string xmlns="http://www.webserviceX.NET">
<?xml version="1.0" encoding="utf-16"?>
<CurrentWeather>
<Location>Mexico City/Licenci, Mexico (MMMX) 19-26N 099-06W</Location>
<Time>Feb 09, 2016 - 11:44 AM EST/2016.02.09 1644 UTC</Time>
<Wind> Calm:0</Wind>
<Visibility> 7 mile(s):0</Visibility>
<SkyConditions> mostly cloudy</SkyConditions>
<Temperature> 51 F (11 C)</Temperature>
<DewPoint> 30 F (-1 C)</DewPoint>
<RelativeHumidity> 43%</RelativeHumidity>
<Pressure> 30.47 in. Hg (1031 hPa)</Pressure>
<Status>Success</Status>
</CurrentWeather>
</string>
-
public class UploadData {
public String getWeather(String city,String country){
String resultado = null;
SoapObject callWS;
callWS = new SoapObject("http://www.webserviceX.NET","GetWeather");
callWS.addProperty("CityName", city);
callWS.addProperty("CountryName",country);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = callWS;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.XSD;
HttpTransportSE androidHttpTranport = null;
try {
String conexion = "http://www.webservicex.com/globalweather.asmx?WSDL";
androidHttpTranport = new HttpTransportSE(conexion);
androidHttpTranport.call("http://www.webserviceX.NET/GetWeather",envelope);
result = envelope.getResponse().toString();
}catch (Exception e){
System.out.println(e.getMessage());
result=e.getMessage();
}
return result;
}}