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;
}
出处:http://www.brtech.com.cn
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |