日期:2014-05-17 浏览次数:20568 次
StringBuilder builder = new StringBuilder(); builder.Append("http://xxx.com.cn/misc.ashx"); builder.Append("?"); builder.Append("action=gold"); builder.Append("&"); builder.Append("token="+strToken+""); HttpWebResponse rsp = null; HttpWebRequest req = null; req = (HttpWebRequest)WebRequest.Create(new Uri(builder.ToString())); req.ContentType = "application/x-www-form-urlencoded"; req.Accept = "*/*"; req.Timeout = 30000;//30秒连接不成功就中断 req.Method = "GET"; rsp = (HttpWebResponse)req.GetResponse(); Stream rspStream = rsp.GetResponseStream(); StreamReader sr = new StreamReader(rspStream, Encoding.GetEncoding("utf-8")); result = sr.ReadToEnd(); sr.Close(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(result);