0

I am creating application in which I want to send data to server in xml So How I can do it ? Here is my code :

DefaultHttpClient httpClient = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost("http://10.0.2.2/test/recevivexml.php");
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1); 
    nameValuePairs.add(new BasicNameValuePair("xmlfile", result_xml));
    try 
    {
        httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse httpResponse = httpClient.execute(httpPost);
        HttpEntity httpEntity = httpResponse.getEntity();
        inputStream = httpEntity.getContent();
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"), 8);
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null) 
        {
            sb.append(line);

        }
        inputStream.close();
        String stresult = sb.toString();
        System.out.println(stresult);
    } 
    catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

0 Answers0