Solved

Handling the response from the "Microsoft.XMLHTTP"

Posted on 2004-08-12
10
188 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to count occurrences of each item in an array.

815 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