title: How to send XML POST request using Apache HttpClient?
body: <p>I want to do a HTTP POST of the format as follows,</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;authRequest&gt;
   &lt;username&gt;someusernamehere&lt;/username&gt;
   &lt;password&gt;somepasswordhere&lt;/password&gt;
  &lt;/authRequest&gt;
  </code></pre>
  
  <p>I usually work with the following mechanism for any login based POST,</p>
  
  <pre><code>HttpParams params = new BasicHttpParams();
          params.setParameter(
                  "http.useragent",
                  "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6");
          DefaultHttpClient httpclient = new DefaultHttpClient(params);
  
          HttpPost httppost = new HttpPost("http://mysite.com/login");
          List&lt;NameValuePair&gt; formparams = new ArrayList&lt;NameValuePair&gt;();
          formparams.add(new BasicNameValuePair("username", "stackoverflow"));
          formparams.add(new BasicNameValuePair("password", "12345"));
          UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
          httppost.setEntity(entity);
          HttpResponse httpresponse = httpclient.execute(httppost);
  </code></pre>
  
  <p>But with this way, the POST data will be look like,</p>
  
  <pre><code>username=stackoverflow&amp;password=12345
  </code></pre>
  
  <p>How can I format this request as per the specified XML format that I mentioned above?</p>
  
  <p>Thanks in advance.</p>