c# - How do I load an xml file and read from it in Silverlight? -


I do not want to load it from any website, I've added it to my project, what I want to do It accesses and read it. Anyone can help!

I found a blog post by which a method has been described. The code is a little long to cite in full, but here is the relevant section:

  stringreader stream = new stringreader (E. result); XmlReader Reader = XmlReader.Create (stream); While (reader.Read ()) {// do stuff}  

Downloading XML file using this code:

  Yuri URL = New Uri ("map image.exml", urchx, relative); Web client client = new webclient (); Client.DownloadStringCompleted + = New DownloadStringCompletedEventHandler (client_DownloadStringCompleted); Client.DownloadStringAsync (url);  

From the MSDN page:

After downloading the resource, this method uses the specified encoding to convert the string into the encoding property. This method does not block the calling thread when downloading resources. To download a resource and block while waiting for the server's response, use the DownloadString method. When the download is complete, the DownloadStringCompleted event is picked up. Your application should handle this event to receive notification. Downloaded string is available in the property property.

Then download this file in your temporary Internet file folder (or cache based on browser) and then sends the file as string , Where you can call it StringReader .

.

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -