apache 将 XML 文件发送到 Android 中的 Web 服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2584376/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Send XML file to web server in Android
提问by jcrowson
I am planning on converting some longitude and latitude values to XML and then sending the file to a web server to display on a Google Map Interface.
我计划将一些经度和纬度值转换为 XML,然后将文件发送到 Web 服务器以显示在 Google 地图界面上。
Is it possible to send an XML file to a web server through my own application in Android?
是否可以通过我自己的 Android 应用程序将 XML 文件发送到 Web 服务器?
Thanks
谢谢
回答by Daniel Magnusson
Yes. Just make a http post with your xml data. You need a web server script that handles the xml you posted to the server aswell.
是的。只需使用您的 xml 数据制作一个 http 帖子。您还需要一个 Web 服务器脚本来处理您发布到服务器的 xml。
回答by Anthony
Android has a public class called HttpPostthat would work fine.
Android 有一个名为的公共类HttpPost,它可以正常工作。
Basically you specify the url that the server that you are sending the HTTP request to and the content of the XML goes into the POST area. The web server will receive the request and, assuming a php script is at the URL, the script can grab the contents via its own $_POSTglobal variable and do with the XML what needs to be done.
基本上,您指定要将 HTTP 请求发送到的服务器的 URL,并且 XML 的内容进入 POST 区域。Web 服务器将接收请求,并且假设 php 脚本位于 URL 处,该脚本可以通过其自己的$_POST全局变量获取内容并使用 XML 执行需要完成的操作。

