嗨,我需要從Web服務獲取數據&把它們放入一個文本塊。通過下一個代碼,它給了我空文本塊是否有任何問題,我的代碼 ?來自web服務的textblock數據
public info()
{
InitializeComponent();
WebClient inf = new WebClient();
// client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
inf.DownloadStringCompleted+=new DownloadStringCompletedEventHandler(inf_DownloadStringCompleted);
//name.Text =
}
public void inf_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
string pass = mp.passwordBox1.Password;
string id = mp.tx.Text;
string url = "http://82.212.89.6:888/mob/resources/stdInfo/authenticate/" +id + "/" +pass + "/1/570322308ce1121cba1b93f5acc9ebd4733ef2bca90ef942a2cfa224f0aa08dc/1";
XElement xx = XElement.Parse(url);
string m= xx.Element("userId").Value;
name.Text = m;
}
你好像離別的網址,而不是它的內容。 – reinierpost 2012-03-15 10:24:31
使用'xmlreader'來讀取結果並解析其內容 – 2012-03-15 10:31:21
我從xmlreader中定義了一個對象,並將它作爲任何類對象調用。 – 2012-03-15 10:38:29