Solved

Reading data from Browser

Posted on 2009-07-02
10
455 Views
Last Modified: 2012-05-07
Hi Experts,

I would like to know the possible ways to do the following.

I have a third party website to which I pass argument.

Something like this

http://www.WebSite.com/?Arg1=value1

This website returns data in xml.

So what I want to do is read the xml that is returned when the url is hit.

How can I read the result returned?

Thanks in advance.
0
Comment
Question by:informaniac
10 Comments
 
LVL 18

Accepted Solution

by:
Ajay Sharma earned 250 total points
Comment Utility
0
 
LVL 9

Expert Comment

by:Rahul Goel
Comment Utility

string lcUrl = "http://www.west-wind.com/TestPage.wwd";
 

 
 

// *** Establish the request 
 

HttpWebRequest loHttp = 
 

     (HttpWebRequest) WebRequest.Create(lcUrl);
 

 
 

// *** Set properties
 

loHttp.Timeout = 10000;     // 10 secs
 

loHttp.UserAgent = "Code Sample Web Client";
 

 
 

// *** Retrieve request info headers
 

HttpWebResponse loWebResponse = (HttpWebResponse) loHttp.GetResponse();
 

 
 

Encoding enc = Encoding.GetEncoding(1252);  // Windows default Code Page
 

 
 

StreamReader loResponseStream = 
 

   new StreamReader(loWebResponse.GetResponseStream(),enc);
 

 
 

string lcHtml = loResponseStream.ReadToEnd();
 

 
 

loWebResponse.Close();
 

loResponseStream.Close();

Open in new window

0
 
LVL 53

Expert Comment

by:Dhaest
Comment Utility
0
 
LVL 9

Expert Comment

by:Rahul Goel
Comment Utility
ajaysharma

Does it contains proxy settings also??
0
 
LVL 20

Author Comment

by:informaniac
Comment Utility
Thanks,

I'll check and revert.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 20

Author Comment

by:informaniac
Comment Utility
Ya proxy will be there. Would there a change in that case?
0
 
LVL 9

Assisted Solution

by:Rahul Goel
Rahul Goel earned 250 total points
Comment Utility
Yeah there will be some change in the code:

WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultNetworkCredentials; 
 

            HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://www.msn.com"); 
 

            //Both works 
 

            req.Proxy.Credentials = CredentialCache.DefaultCredentials; 
 

            //req.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials; 
 

            WebResponse rsp = req.GetResponse(); 
 

            Stream s = rsp.GetResponseStream(); 
 

            StreamReader r = new StreamReader(s); 

Open in new window

0
 
LVL 3

Expert Comment

by:coagantus
Comment Utility
try this code and after that u can get your required xml and use it...
string link= "http://www.WebSite.com/?Arg1=value1"; 

WebRequest req = WebRequest.Create(link);

WebResponse res= req.GetResponse(); 

StreamReader stream = new StreamReader(res.GetResponseStream(),Encoding.Default);

string body = stream.ReadToEnd();

res.Close(); 

stream.Close();

Open in new window

0
 
LVL 7

Expert Comment

by:Seo_Expert
Comment Utility
Hello

Below url will help you solve your problem.

http://www.codeproject.com/KB/aspnet/UsePayPalPaymentInASPNET.aspx
0
 
LVL 20

Author Closing Comment

by:informaniac
Comment Utility
Sorry for closing the question late. But the response time of the experts was great.
Thanks once again.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

728 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

9 Experts available now in Live!

Get 1:1 Help Now