Solved

Reading data from Browser

Posted on 2009-07-02
10
487 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
ID: 24770366
0
 
LVL 9

Expert Comment

by:Rahul Goel ITIL
ID: 24770390

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
ID: 24770391
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 9

Expert Comment

by:Rahul Goel ITIL
ID: 24770399
ajaysharma

Does it contains proxy settings also??
0
 
LVL 20

Author Comment

by:informaniac
ID: 24770418
Thanks,

I'll check and revert.
0
 
LVL 20

Author Comment

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

Assisted Solution

by:Rahul Goel ITIL
Rahul Goel ITIL earned 250 total points
ID: 24770434
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
ID: 24770453
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
ID: 24770533
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
ID: 31599464
Sorry for closing the question late. But the response time of the experts was great.
Thanks once again.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.Net. Reading xml value 6 30
ASP.NET (VB) return a record 2 40
Input parameteres to DragOver 2 20
need to convert function to c# 5 31
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 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