Solved

Save HttpWebResponse XML file to Local Computer

Posted on 2007-11-15
2
1,115 Views
Last Modified: 2013-11-26
Hi,

I "get" (download) a XML file using the code listed below.

How can I save that to a local file? For the life of me I can't figure it out.

Thanks
Dim wr As HttpWebRequest = _

                CType(WebRequest.Create("http://thewebsite.com/thexmlfile.xml"), HttpWebRequest)

        Dim wrp As HttpWebResponse = CType(wr.GetResponse, HttpWebResponse)

        Dim s As Stream = wrp.GetResponseStream

Open in new window

0
Comment
Question by:ALawrence007
2 Comments
 
LVL 22

Accepted Solution

by:
Snarf0001 earned 500 total points
ID: 20289974
Use streamreader and streamwriter objects
I use c# instead of VB, so forgive me if syntax is off a bit, but something like the following:

Dim wr as HttpWebRequest = HttpWebRequest.Create("http://thewebsite.com/thexmlfile.xml")
Dim wrp as HttpWebResponse = wr.GetResponse

Dim sr as StreamReader = new StreamReader(wrp.GetResponseStream)
Dim sw as StreamWriter = new StreamWriter("thelocalxmlfile.xml", false)
sw.Write(sr.ReadToEnd)
sr.Close
sw.Close
0
 

Author Comment

by:ALawrence007
ID: 20291308
Thanks Snarf0001!
Worked like a charm!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now