我有一个PHP脚本,它使用'echo'命令和数据库中的数据生成XML。 因此,如果我从浏览器访问此脚本,我可以看到xml数据并下载它。如何使用WebClient下载PHP脚本生成的XML内容?
所以我写一个软件来检索这个数据使用webclient类。但webclient只下载一个空文件,所以我想它试图下载.php文件,而不是生成的动态内容。
PHP脚本发送header("Content-type: text/xml")
,Web客户端尝试从https://mySecureServer.com/db/getXMLData.php
下载(也许这是问题)。
任何想法?
编辑:Web客户端代码(只是撕开了一些本地的文件操作):
string url = @"https://mySecureServer.com/db/getXMLData.php";
WebClient client = new WebClient();
client.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCompletedEvtHdl);
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChangedEvtHdl);
client.BaseAddress = @"https://mySecureServer.com/db/";
client.DownloadFileAsync(new Uri(url), toSavePath + filename);
Webclient无法下载.php文件,因为这是永远不可用的。 – 2010-09-01 17:07:29
请显示您正在使用的代码下载。 – 2010-09-01 17:08:07