登录并通过HTTP下载一个XML文件?

问题描述:

需要登录,并从以下网址下载xml文件:

Need to login and download xml file from the below url :

http://www.radionyhetene.net/download/nyheter/mp3/ nyheter.xml

我已经知道如何获取并使用Web客户端发布数据,HttpWebRequest的。但对于上面的网址,我一点都能够明白该怎么做。

I already know how to get and post data using WebClient ,HttpWebRequest .But for the above url ,I am not at all able to understand what to do .

我试图使用Live HTTP标头的上面的URL。它显示是这样的:

I tried using Live Http Header for the above Url . It shows something like this :

http://www.radionyhetene.net/download/nyheter/mp3/nyheter.xml
GET /download/nyheter/mp3/nyheter.xml HTTP/1.1
Host: www.radionyhetene.net
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115                Firefox/3.6
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Authorization: Basic aGF1Z2FsYW5kOjlmNm5kOGtmMw==

HTTP/1.1 200 OK
Date: Fri, 30 Mar 2012 16:09:35 GMT
Server: Apache/2.2.15 (Win32) PHP/5.3.2
Last-Modified: Fri, 30 Mar 2012 14:54:13 GMT
Etag: "4730000000053f1-194-4bc77038957a2"
Accept-Ranges: bytes
Content-Length: 404
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/xml

所以,问题是如何能我通过登录信息到这个网址?请提供您的有关建议。
谢谢你。

So the question is how can I pass login information to this url ? Kindly provide your suggestion regarding. Thanks.

易,

WebClient web = new WebClient();
web.Credentials = new NetworkCredential("h.....", "9.......");
string s = web.DownloadString("http://www.radionyhetene.net/download/nyheter/mp3/nyheter.xml");