Reputation: 622
Hello i am developing application for windows phone and i want to read an xml from the web so i am using on page loaded event :
Dim cl As New WebClient
AddHandler cl.DownloadStringCompleted, AddressOf cl_DownloadStringCompleted
cl.DownloadStringAsync(New Uri("demo.com/1.xml",UriKind.RelativeOrAbsolute))
and on cl.DownloadStringCompleted event :
Dim doc = XDocument.Load("demo.com/1.xml")
but for some reason i crashes ! the bug must be that i have not to use URI : "demo.com/1.xml" , but some else :S
Upvotes: 0
Views: 308
Reputation: 12465
The DownloadStringCompleted
event has DownloadStringCompletedEventArgs
. You should use the Result property of those args.
Dim client As New WebClient()
AddHandler client.DownloadStringCompleted, AddressOf ClientOnDownloadStringCompleted
client.DownloadStringAsync(New Uri("http://demo.com/xml"))
and the handler:
Private Sub ClientOnDownloadStringCompleted(sender As Object, args As DownloadStringCompletedEventArgs)
Dim doc = XDocument.Parse(args.Result)
End Sub
Upvotes: 1