Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Handling the response from the "Microsoft.XMLHTTP"

Posted on 2004-08-12
10
200 Views
Last Modified: 2010-05-18
I have successfully set up a chunk of code using GET within  CreateObject("Microsoft.XMLHTTP") but am having problems dealing with the returned data.

I can use  reponse.txt   but this just gives me a text representation of the body. What I want to do is gather the full response and allocate it to variable names (or use the XML names - I don't mind) and display the data in a meaningful fashion within an ASP page. I notice the text command misses out empty fields completely; I would need this to come through as fields but empty - in the same way as is shown when the raw XML feed is displayed if you don't use the XMLHTTP object.

Can anybody help me?
0
Comment
Question by:Laride
  • 4
  • 2
  • 2
10 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 11783242
try using GetResponseStream:

Response.GetResponseStream

P.S What programming language are you using?
0
 

Author Comment

by:Laride
ID: 11783568
I'm using VBScript and old fashioned ASP. Isn't GetREsponseStream a .NET feature?

I don't do .NET - not yet anyway and certainly not for this project due to time constaints.
0
 
LVL 35

Expert Comment

by:YZlat
ID: 11787440
try setting response' content type


Response.ContentType = "text/xml"
dim objXMLHTTP
set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objXMLHTTP.Open "GET", sourceURL,false
objXMLHTTP.SetRequestHeader "Content-type", "text/xml"
objXMLHTTP.Send
Response.Write objXMLHTTP.ResponseText


0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:Laride
ID: 11787921
That's pretty much exactly the code I have used so far. The response.Write XMLHTTP.reponse.Text gives me a long string which I don't actually want . I want to get the response back as neat little bundles of text to which i can assign a variable name to  each one and then display them individually in my web page.
0
 

Author Comment

by:Laride
ID: 11818203
Any further comments before I terminate the question with no points awarded?
0
 
LVL 8

Expert Comment

by:OBonio
ID: 11820096
Load the XMLTTP.response.Text property into an XmlDocument object, then you can traverse the XML however you want, outputting data how you want.

You could also use an XSLT to convert the response into what you want.
0
 

Author Comment

by:Laride
ID: 11820219
That sounds interesting OBonio. Sorry to be dense but how exactly would I do that?

0
 
LVL 8

Accepted Solution

by:
OBonio earned 250 total points
ID: 11825637
If the response is valid XML, then simply load it with :

Dim xmlDOM = Server.CreateObject("MSXML.DOMDocument")

xmlDOM.LoadXML(XMLHTTP.Response.Text)

or you could just

xmlDOM.Load("http://myurl/")

Then it's just a case of recursing through the XML nodes outputting what you want :

Take a look here to discover more about the wonders of XML :

http://www.perfectxml.com/msxmlDOM.asp

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Getting Started on web Development for an experienced C++ developer 7 125
Questions about this React unit test 4 66
Animated .jpg? 13 97
How to write an English digest paper 6 72
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

860 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