Solved

Handling the response from the "Microsoft.XMLHTTP"

Posted on 2004-08-12
10
168 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
 

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

747 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

11 Experts available now in Live!

Get 1:1 Help Now