调用webservice,解析返回数据为xml格式的字符串,进行数据绑定

时间:2023-03-09 00:38:26
调用webservice,解析返回数据为xml格式的字符串,进行数据绑定
DataSet ds = new DataSet();
byte[] byteArray = System.Text.Encoding.Unicode.GetBytes("<?xml version='1.0'?><roots><root><id>1</id><name>张三</name></root><root><id>1</id><name>张三</name></root></roots>");
System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
ds.ReadXml(stream);
DataTable dt = ds.Tables[0];

这个地方 System.Text.Encoding.Unicode 要注意编码格式