これを試して
string sVal = "http://www.w3schools.com/xml/note.xml";
XDocument document = XDocument.Load(sVal);
また
Uri url = new Uri("http://www.w3schools.com/xml/note.xml");
using (var wc = new WebClient())
{
string sss = wc.DownloadString(url);
}
セキュリティの問題に直面している場合
これを試して
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "GET";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
// allows for validation of SSL conversations
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
WebResponse respon = req.GetResponse();
Stream res = respon.GetResponseStream();
string ret = "";
byte[] buffer = new byte[1048];
int read = 0;
while ((read = res.Read(buffer, 0, buffer.Length)) > 0)
{
Console.Write(Encoding.ASCII.GetString(buffer, 0, read));
ret += Encoding.ASCII.GetString(buffer, 0, read);
}
return ret;
また
private void Test()
{ ServicePointManager.ServerCertificateValidationCallback += new
RemoteCertificateValidationCallback(Certificate);
}
private static bool Certificate(object sender, X509Certificate certificate,
X509Chain chain, SslPolicyErrors policyErrors) {
return true;
}
詳細については、このリンクを確認してくださいhttp://blogs.msdn.com/b/dgorti/archive/2005/09/18/471003.aspx