用于Windows手机的VB silverlight“DownloadStringAsync”

时间:2012-05-10 20:05:29

标签: vb.net silverlight windows-phone-7

您好我正在为Windows手机开发应用程序,我想从网上读取xml 所以我在页面加载的事件上使用:

Dim cl As New WebClient AddHandler cl.DownloadStringCompleted, AddressOf cl_DownloadStringCompleted cl.DownloadStringAsync(New Uri("demo.com/1.xml",UriKind.RelativeOrAbsolute))

和cl.DownloadStringCompleted事件:

Dim cl As New WebClient AddHandler cl.DownloadStringCompleted, AddressOf cl_DownloadStringCompleted cl.DownloadStringAsync(New Uri("demo.com/1.xml",UriKind.RelativeOrAbsolute))

但由于某种原因我崩溃了! 错误必须是我不能使用URI:“demo.com/1.xml”,但其他一些:S

1 个答案:

答案 0 :(得分:1)

DownloadStringCompleted事件有DownloadStringCompletedEventArgs。您应该使用那些args的Result属性。

Dim client As New WebClient()
AddHandler client.DownloadStringCompleted, AddressOf ClientOnDownloadStringCompleted
client.DownloadStringAsync(New Uri("http://demo.com/xml"))

和处理程序:

Private Sub ClientOnDownloadStringCompleted(sender As Object, args As DownloadStringCompletedEventArgs)
    Dim doc = XDocument.Parse(args.Result)
End Sub
相关问题