Note that there are some explanatory texts on larger screens.

plurals
  1. POQuery about xml parsing in android
    text
    copied!<p>I am working on an android app in which i have to fetch data from a .Net webservice Initially methods of webservice returning simple strings.That's fine my code is working fine and fetch strings smoothly.But my problem starts when methods return objects,I know object holds the data in XML form.I also confirmed it by debugging my code,the resultant object holds the data given below. </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;soap:Body&gt; &lt;UserInfoResponse xmlns="http://tempuri.org/"&gt; &lt;UserInfoResult&gt; &lt;UserName&gt;Himanshu&lt;/UserName&gt; &lt;Email&gt;Himanshu@XXXXXXXX.com&lt;/Email&gt; &lt;/UserInfoResult&gt; &lt;/UserInfoResponse&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre> <p>and my code to consume the web service is:-</p> <pre><code>public void objData(){ SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME2); Log.d("request", request.toString()); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); Log.d("envelope", envelope.toString()); envelope.dotNet = true; envelope.setOutputSoapObject(request); Log.d("envelope", envelope.toString()); HttpTransportSE aht = new HttpTransportSE(URL); aht.debug=true; Log.d("aht", aht.toString()); try { aht.call(OBJ_SOAP_ACTION, envelope); SoapPrimitive results = (SoapPrimitive)envelope.getResponse(); System.out.println("results="+results); tv4.setText(""+results); } catch (Exception e) { tv4.setText(e.getClass().toString()); Log.d("Error",e.getClass().toString()); } } </code></pre> <p>The object <code>results</code> holds the xml data.Now my problem is that when i print the data of that object by using the code <code>tv4.setText(""+results);</code> it gives me <code>class java.lang.ClassCastException</code>.I know that this is not the right approach to get object's xml data,I have to parse it.But i dont know how to parse object.So please help me to parse xml contained object.Any help would be highly appreciated.Thanx in advance. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload