locked
get data from xml file RRS feed

  • Question

  • I have copy a xml file to the "clientbin" folder

    when i need to call the xml file in the silverlight.

    Dim url As New Uri("advBranch.xml", UriKind.Relative)
     Dim xmlClient As New WebClient()

     xmlClient.DownloadStringCompleted += New DownloadStringCompletedEventHandler(XMLFileLoaded)


    this statement

    " xmlClient.DownloadStringCompleted += New DownloadStringCompletedEventHandler(XMLFileLoaded)"


    I have an error for the above statement. any one can tell me what is the problem???

    Friday, May 13, 2011 7:05 AM

Answers

  • In VB.NET, use

    AddHandler xmlClient.DownloadStringCompleted, AddressOf DownloadStringCompletedEventHandler

    instead of

    xmlClient.DownloadStringCompleted += New DownloadStringCompletedEventHandler(XMLFileLoaded)

    Hope this help!

    Friday, May 13, 2011 7:47 AM

All replies

  • tyr this
    WebClient xmlClient = new WebClient();xmlClient.DownloadStringCompleted += newDownloadStringCompletedEventHandler(XMLFileLoaded);xmlClient.DownloadStringAsync(new Uri("advBranch.xml",UriKind.RelativeOrAbsolute));void XMLFileLoaded(object senderDownloadStringCompletedEventArgse){if (e.Error == null){string xmlData = e.Result;HtmlPage.Window.Alert(xmlData);}}

    Friday, May 13, 2011 7:15 AM
  • same problem,

    cannot


    but got show this message

    'Public Event DownloadStringComplete(sender As Object,e As System.Net.DownloadStringCompleteEventArgs)'

    is an Event, and cannot be called directly.Use "RaiseEvent" statement to raise an event


    what is means add Raise Event

    Friday, May 13, 2011 7:27 AM
  • the above code is working fine in my side share modified code 

    Friday, May 13, 2011 7:29 AM
  • then how should i do, just ignore it?

    Friday, May 13, 2011 7:40 AM
  • In VB.NET, use

    AddHandler xmlClient.DownloadStringCompleted, AddressOf DownloadStringCompletedEventHandler

    instead of

    xmlClient.DownloadStringCompleted += New DownloadStringCompletedEventHandler(XMLFileLoaded)

    Hope this help!

    Friday, May 13, 2011 7:47 AM
  • In VB.NET, use

    AddHandler xmlClient.DownloadStringCompleted, AddressOf DownloadStringCompletedEventHandler


    thanks for helping, it help me alot.

    Friday, May 13, 2011 9:45 PM