Solved

Handling the response from the "Microsoft.XMLHTTP"

Posted on 2004-08-12
10
221 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
[X]
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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
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 …
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.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

707 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