Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get JSON from an XML response from server?
    primarykey
    data
    text
    <p>My android application sends a web service request and gets the response from web service in xml, with the embedded data in JSON. I am saving this in a string. Now I do not know how to get the JSON data from this string.</p> <pre><code> System.setProperty("http.keepAlive", "false"); // request parameters HttpParams params = httpClient.getParams(); HttpConnectionParams.setConnectionTimeout(params, 10000); HttpConnectionParams.setSoTimeout(params, 15000); // set parameter HttpProtocolParams.setUseExpectContinue(httpClient.getParams(), true); // POST the envelope HttpPost httppost = new HttpPost(url); // add headers httppost.setHeader("SOAPAction", soapAction); httppost.setHeader("Content-Type", "text/xml; charset=utf-8"); // httppost.setHeader("Content-Length", // String.valueOf(requestEnvelope.length())); httppost.setHeader("SOAPAction", "http://tempuri.org/" + methodName); // String responseString = ""; try { // the entity holds the request HttpEntity entity = new StringEntity(requestEnvelope); httppost.setEntity(entity); HttpResponse response = httpClient.execute(httppost); String result = EntityUtils.toString(response.getEntity()); </code></pre> <p>This is the response from the server, which I get in the result string.</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;ValidatePassCodeResponse xmlns="http://tempuri.org/"&gt; &lt;ValidatePassCodeResult&gt; [{"ID":1929,"Headline":"Test News","Detail":"","SubmitDate":"1/17/2012 12:08:04 PM"}] &lt;/ValidatePassCodeResult&gt; &lt;/ValidatePassCodeResponse&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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