嗨,我需要从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