简体   繁体   English

如何在Andorid中解析Web服务的XML响应

[英]How To Parse XML Respond Of Web Service In Andorid

Hi Guys I am new to Ksoap. 嗨,大家好我是Ksoap的新手。 I manage to some work on the Web Services in android but Now I am unable to find out how can I parse the XML respond of the Web Service Please Help Me. 我设法在android的Web服务上进行了一些工作,但是现在我无法找出如何解析Web服务的XML响应,请帮助我。

The XML In Response XML作为回应

anyType
{
schema=anyType
{
element=anyType
{
complexType=anyType
{
choice=anyType
{
element=anyType
{
complexType=anyType
{
sequence=anyType
{
element=anyType{}; 
element=anyType{}; 
element=anyType{}; 
element=anyType{}; 
element=anyType{};
element=anyType{}; 
}; }; }; };  };  }; }; 

diffgram=anyType
{
MobileApp=anyType
{
tbl_Vehicles=anyType
{
 ID=1; 
 PlateNumber=95459;
 Latitude=25.167330;
 Longitude=55.237670;
 Status=Driving;
 Location=Sheikh Zayed Rd. Dubai; 
}; 

tbl_Vehicles=anyType
{
ID=2; 
PlateNumber=45926;
Latitude=25.127791; 
Longitude=55.114626;
Status=Parked;
Location=Alpha Tours, Palm Jumeirah, Dubai; 
}; 
}; 
}; 
}

My Code Is As Follow 我的代码如下

public void getVehicleList()
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);       

request.addProperty("UserID", id );

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

envelope.setOutputSoapObject(request);
envelope.dotNet = true;

try 
{
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
    androidHttpTransport.call(SOAP_ACTION_LOGIN, envelope);


    if (envelope.bodyIn instanceof SoapFault) 
    {
        String str = ((SoapFault) envelope.bodyIn).faultstring;
        Log.i("SoapFault", str);
        showDialog("Error", "Their Is Some Problem In Server Response");
    } 
    else 
    {
        SoapObject response = (SoapObject)envelope.bodyIn;

        Log.d("Veh ID 8", "Result = " + response.toString() );
   }
} 
catch (Exception e) 
{
      e.printStackTrace();
}

} }

也许您因为响应不是XML而很难受吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM