【发布时间】:2012-08-20 01:40:22
【问题描述】:
我想在 Textblock 中显示我的 Json 字符串。
我的 C# 代码是:
namespace JsonDemo
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
WebClient wc = new WebClient();
wc.DownloadStringAsync(
new Uri("http://192.168.1.32/test/NadalApp.asmx/GetCityDetails"));
wc.DownloadStringCompleted +=
new DownloadStringCompletedEventHandler(
wc_DownloadStringCompleted);
}
void wc_DownloadStringCompleted(object sender,
DownloadStringCompletedEventArgs e)
{
string str = e.Result.Replace("</string>", "");
str = str.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "");
str = str.Replace("<string xmlns=\"http://tempuri.org/\">", "");
Debug.WriteLine("Web service says: " + str);
}
我通过 Web 服务在 e.Result 上获得了我的 json 字符串。现在如何解析我的字符串并显示文本块?
【问题讨论】:
标签: windows-phone-7