#region 接口返回的Xml转换成DataSet
/// <summary>
/// 返回的Xml转换成DataSet
/// </summary>
/// <param name="text">Xml字符</param>
/// <returns></returns>
private DataSet GetDataSet(string text)
{
try
{
XmlTextReader reader = new XmlTextReader(new StringReader(text));
reader.WhitespaceHandling = WhitespaceHandling.None;
DataSet ds = new DataSet();
ds.ReadXml(reader);
reader.Close();
ds.Dispose();
return ds;
}
catch
{
return null;
}
}
#endregion
#region 后台提交数据且获取接口返回的数据
/// <summary>
/// 后台提交数据且获取接口返回的数据
/// </summary>
/// <param name="relativePath">地址</param>
/// <returns></returns>
public static string GetRequestString(string relativePath)
{
string requestUrl = relativePath;
try
{
// 创建一个HTTP请求
HttpWebRequest request = (System.Net.HttpWebRequest)WebRequest.Create(requestUrl);
request.Method = "GET";
StreamReader jsonStream = new StreamReader(request.GetResponse().GetResponseStream());
string jsonObject = jsonStream.ReadToEnd();
return jsonObject;
}
catch
{
return string.Empty;
}
}
#endregion
[C#]Winform后台提交数据且获取远程接口返回的XML数据,转换成DataSet,布布扣,bubuko.com
[C#]Winform后台提交数据且获取远程接口返回的XML数据,转换成DataSet