public dataset getdata(string httpurl)
{
string xmlpath = @"http地址"; // 該地址不能包含中文
dataset ds = new dataset();
webclient wc = new webclient();
byte[] bt = wc.downloaddata(xmlpath);
xmldocument xd = new xmldocument();
string source = byte2string(bt);
xd.loadxml(source);
xmlnodereader xnr = new xmlnodereader(xd);
ds.readxml(xnr);
datatable dt = ds.tables[0];
this.datagrid1.datasource = ds;
this.datagrid1.databind();
return ds;
}
public static string byte2string(byte[] bt)
{
system.text.encoding encoding = system.text.encoding.getencoding("gb2312");
string str = encoding.getstring(bt);
return str;
}
,歡迎訪問網頁設計愛好者web開發。
新聞熱點
疑難解答