110,502
社区成员
发帖
与我相关
我的任务
分享
string text = this.tbUser.Text;
string str = this.mtbPsw.Text;
string s = "username=" + HttpUtility.UrlEncode(text) + "&pwd=" + HttpUtility.UrlEncode(str);
byte[] bytes = Encoding.UTF8.GetBytes(s);
WebClient client = new WebClient();
client.Encoding = Encoding.GetEncoding("utf-8");
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
client.Headers.Set("Content-Type", "application/x-www-form-urlencoded");
byte[] buffer2 = null;
try
{
buffer2 = client.UploadData("http://localhost:4137/User_Login.ashx", "POST", bytes);
}
catch (Exception)
{
MessageBox.Show("服务器未响应");
return;
}
string xml = Encoding.UTF8.GetString(buffer2);
public static string CDataToXml(DataTable dt)
{
if (dt != null)
{
MemoryStream ms = null;
XmlTextWriter XmlWt = null;
try
{
ms = new MemoryStream();
//根据ms实例化XmlWt
XmlWt = new XmlTextWriter(ms, Encoding.Unicode);
//获取ds中的数据
dt.WriteXml(XmlWt);
int count = (int)ms.Length;
byte[] temp = new byte[count];
ms.Seek(0, SeekOrigin.Begin);
ms.Read(temp, 0, count);
//返回Unicode编码的文本
UnicodeEncoding ucode = new UnicodeEncoding();
string returnValue = ucode.GetString(temp).Trim();
return returnValue;
}
catch (System.Exception ex)
{
throw ex;
}
finally
{
//释放资源
if (XmlWt != null)
{
XmlWt.Close();
ms.Close();
ms.Dispose();
}
}
}
else
{
return "";
}
}
CDataToXml 方法。
现在解析出来是
<NewDataSet><Table><Id>1</Id><MemberId>salman</MemberId><password>30F631B1B6C02143C58DD41D9B347781</password><Finance>536.927</Finance><ConUrl>http://localhost:4137/Notify.aspx</ConUrl><ConName>bbb</ConName><ConKey>444f672de871d26c0b6b7014882e8394</ConKey></Table></NewDataSet>
这样的。我想不要前后的NewDataSet ,应该如何做?