如何从此xml站点(http://xboxapi.duncanmackenzie.net/gamertag.ashx?GamerTag=Festive+Turkey)获取数据并指定数据并将其用作字符串?
使用WebClient对象
public static string GetWebPage(Uri uri) {
if ((uri == null)) {
throw new ArgumentNullException("uri");
}
using (var request = new WebClient()) {
//Download the data
var requestData = request.DownloadData(uri);
//Return the data by encoding it back to text!
return Encoding.ASCII.GetString(requestData);
}
}
Run Code Online (Sandbox Code Playgroud)