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
Related Q & A:
- how delete node in xml file using php?Best solution by Stack Overflow
- How to Read xml file in java?Best solution by Stack Overflow
- How to convert build.xml to maven pom.xml file?Best solution by Stack Overflow
- How to write XML file with Java and read it?Best solution by Stack Overflow
- How to convert a HTML file to XML file?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.