C# - 从在线xml文件中获取数据

use*_*419 3 c#

如何从此xml站点(http://xboxapi.duncanmackenzie.net/gamertag.ashx?GamerTag=Festive+Turkey)获取数据并指定数据并将其用作字符串?

Jho*_*re- 6

使用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)