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开发。
新闻热点
疑难解答