How to read xml returned by a WebService in a IE?

This how to shows how you can read the XML which is returned by a WebService and displayed in raw XML in IE.
fozylet submitted the solution for that question in the forums. I have converted his VB.NET code to C#.

Used Classes:



void Page_Load(object sender, System.EventArgs e)
    StreamReader StreamHandler;
    XmlDocument xmlDoc = new XmlDocument();

    string strURL = "";

    HttpWebRequest wRequest = (HttpWebRequest)WebRequest.Create(strURL);
    wRequest.Headers.Add("Man", "GET " + strURL);
    HttpWebResponse wResponse = (HttpWebResponse)wRequest.GetResponse();
      if(wResponse.StatusCode == HttpStatusCode.OK){
        StreamHandler = new System.IO.StreamReader(wResponse.GetResponseStream());



Filed under:


# Christian Weyer said:

This is not a SOAP-based Web service, as you might already know. This is plain HTTP GET.
Why don't you use the cleint-side ASMX features to 'seamlessly' call the Service via SOAP and the proxy classes? With your approach you have the raw XML - and then?

Just curious ... because there is a solution to get down to the raw XML with the common ASMX-based approach.

Saturday, July 17, 2004 6:36 AM
# Sonu Kapoor said:

Christian, do you have any example for your approach. Honestly said I am new in the world of WebServices and SOAP (or Shampoo (Joking)). I would love to see how it works. Thanks anway for the information. I will try to find something about it.

Saturday, July 17, 2004 6:50 AM
# rob said:


Response.Write(xmlDoc.InnerText) will write on your page the whole XML document.

In this case, it's alright because the XML is very simple.

But what if the XML had more than one element and you only wanted one particular element? In other words, how do you select only parts of that xml you are getting and not the whole thing?

Saturday, July 17, 2004 1:53 PM
# Sonu Kapoor said:

Rob, the xml is stored in the xmlDoc object. That object can be used with the function SelectSingleNode to retrieve one node or SelectNodes to retrieve a list of specific nodes. Hope that helps!

Saturday, July 17, 2004 4:17 PM
# dragonimp said:

You can call remote procedure via webservice but how can you do that with xmlobject? It costs you too much. (.Text could be an example)
I think xmldom can be used in simple situation without webservice supporting.

Monday, July 26, 2004 5:13 AM
# oem software said:

Ayrs7F I really liked your blog article.Much thanks again. Will read on...

Wednesday, May 2, 2012 4:07 PM
# Lovett said:

Thanks for this post, I am a big fan of this website want to go on updated.

Thursday, January 10, 2013 10:03 AM
# Arsenault said:

it's always a fine idea to search out event planners when you want a fine outcome for your planned event“

Monday, January 28, 2013 9:48 AM
# Spaulding said:

Thanks for any other magnificent article. Where else may

just anybody learn that kind of info in such a perfect tactic of writing?

I have a presentation next week, and I’m on that the look for such info.

Tuesday, March 5, 2013 1:48 AM
# Robles said:

Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point.

You clearly know what youre talking about, why waste your intelligence on just posting videos to your site when you could

be giving us something enlightening to read?

Wednesday, April 17, 2013 4:38 PM