I am working on a Geocoding app where I put the address in the URL and retreive the XML. I need the complete XML response for this project. Is there any other class for downloading the XML from a website that may be faster than using WebClient or HttpWebRequest? Can the XMLReader be used to get the full XML without string manipulation and would that be faster and/or more efficient?
views:
73answers:
2Well you can use XmlReader.Create(uri)
- but that's likely to use HttpWebRequest
under the hood, I should think. I doubt that there's a completely separate HTTP client implementation. One advantage of downloading first and then parsing is that if there's anything wrong with the document, it's easier to log the whole thing if you've got it in memory first.
Also, using a separate HttpWebRequest
(or WebClient
) gives you more control over proxies, handling redirection, authentication etc. That may or may not be relevant for your use case, of course.
Have you tried coding this in the simplest way you can think of and then found there to be a performance bottleneck? I'd expect the main issue to be in the network, not in local client processing.
The XDocument.Load method can also do the trick ... but I really doubt it will be faster than any of the other alternatives. It's very convenient, though! :)