Another way which i found over web that how to send xml file to a web server:For this you need to add a jar file "commons-httpclient.jar" in your project. (How to add jar file is clearly mentioned by ChristianB in above/below post)
You can download this jar file from http://www.java2s.com/Code/Jar/ABC/Downloadcommonshttpclientjar.htm2.code would be...
import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.InputStreamRequestEntity; import org.apache.commons.httpclient.methods.PostMethod; import java.io.File; import java.io.FileInputStream; class ClassName extends Activity { public void Sync(View v) // on button click { File xmlFile = new File("sdcard/contacts.xml"); FileInputStream fis = new FileInputStream(xmlFile); InputStreamRequestEntity isre = new InputStreamRequestEntity(fis); /*now pass url of server in constructor of PostMethod*/ PostMethod post = new PostMethod("http://w3mentor.com/Upload.aspx"); post.setRequestEntity(isre); post.setRequestHeader("Content-Type", "text/xml"); HttpClient httpclient = new HttpClient(); int response = httpclient.executeMethod(post); String res = post.getResponseBodyAsString(); Toast.makeText(GetContacts.this, new Integer(response).toString()+""+res, Toast.LENGTH_LONG).show(); post.releaseConnection(); } }