这是这个问题的后续行动:How to load XML into a DataTable?如何使用Web代理从互联网读取XML?
我想读取一个在互联网上的XML文件到一个DataTable。 XML文件是在这里:http://rates.fxcm.com/RatesXML
如果我做的:
public DataTable GetCurrentFxPrices(string url)
{
WebProxy wp = new WebProxy("http://mywebproxy:8080", true);
wp.Credentials = CredentialCache.DefaultCredentials;
WebClient wc = new WebClient();
wc.Proxy = wp;
MemoryStream ms = new MemoryStream(wc.DownloadData(url));
DataSet ds = new DataSet("fxPrices");
ds.ReadXml(ms);
DataTable dt = ds.Tables["Rate"];
return dt;
}
它工作正常。我正在为如何使用Internet Explorer中的默认代理服务器而苦苦挣扎。我不想对代理进行硬编码。如果在Internet Explorer中没有指定代理,我也希望代码能够工作。
作品十分感谢,但我得到一个警告,它在弃用Visual Web Developer 2010 Express。 – 2011-01-11 13:54:12