How to save server response which is in xml format into String variable in android? -


this question has answer here:

i have app in have send string request server , server sending me response in xml format.how can read response ans save in string variable , convert json.

server reponding reponse like:-

<response> <st-code>0</st-code> <st-desc>transaction successful</st-desc> <st-no>xxxxxx</st-no> <st-tno>111111</st-tno> <st-optno>xxxxxxxxx</st-optno> 

  • download following library java-json
  • add library /libs of project
  • now import required libraries
    import org.json.jsonexception;
    import org.json.jsonobject;
    import org.json.xml;
  • now use following code convert xml string json

    samplexml = "";//xml string convert json jsonobject jsonobj = null; try  {     jsonobj = xml.tojsonobject(samplexml); }  catch (jsonexception e)  {     log.e("json exception", e.getmessage());     e.printstacktrace(); }   log.d("xml", samplexml);  log.d("json", jsonobj.tostring()); 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -