How to Read Binary File to XML?

VB 2008 - Read XML file directly from URL?

  • I'm guessing it is possible to read the xml file without downloading it. Although, I can't get it to read from a URL using something such as: Reader = New XmlTextReader("http:\\www.website.com/xm… as you would with a local file. Any help to get this to work would be appreciated. Thanks.

  • Answer:

    Hey Blondehh. To get the xml source you'll need to download the page code. You can achieve this fairly easy with .NET. It should work for XML, I normally use this for HTML code. Here's the code I normally use for downloading data from the internet. public string GetWeb(string url) { StringBuilder sb = new StringBuilder(); byte[] buf = new byte[8192]; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Proxy.Credentials = CredentialCache.DefaultCredentials; request.UseDefaultCredentials = true; request.UserAgent = "Computer"; HttpWebResponse response; try { response = (HttpWebResponse)request.GetResponse(); } catch (WebException we) { return ""; } Stream resStream = response.GetResponseStream(); StreamReader strmReader = new StreamReader(resStream, Encoding.UTF8); string respStr = strmReader.ReadToEnd(); strmReader.Close(); response.Close(); return respStr; } } You can change the encoding and useragent to what ever suits. So "string pagecode = GetWeb("http://answers.yahoo.com");" should give you yahoo's homepage's source code. Hope that's what you were looking for. Cheers, - D.E.

Blondehh at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.