Solved

How can I check the return of objBinaryStream.Write objXMLHTTP.responseBody to see if it's what I want?

Posted on 2008-10-13
4
644 Views
Last Modified: 2012-05-05
Experts,

I have a function that I'm using to download images. I need to edit the URL so I try and get the large verion of the image URL I have. In some cases the largerURL is doesn't exists and I get an XML file returning an error.

Is it possible to check objBinaryStream.Write objXMLHTTP.responseBody to see if it's an image or an xml file?

If so how would I go about it? If not how can I cater for this problem?
0
Comment
Question by:Denisdh
[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
  • 2
4 Comments
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 275 total points
ID: 22707068
Hi, perhaps you could just use the InStr function on the responseBody to test for HTML / XML code, before writing the data to a file?

If InStr(LCase(objXMLHTTP.responseBody), "<xml") > 0 Then
   MsgBox "File is not a binary file."
Else
   objBinaryStream.Write objXMLHTTP.responseBody
End If

Regards,

Rob.
0
 

Author Comment

by:Denisdh
ID: 22712925
Hey,

I've tried the following with no luck. <?xml is in the files that it downloads but this code doesn't seem to catch it.

Any other suggestions?


If InStr(LCase(objXMLHTTP.responseBody), "<?xml") > 0 Then
  Response.Write("XML File Found, no image at this URL")
End If

Open in new window

0
 
LVL 7

Assisted Solution

by:bluV11t
bluV11t earned 225 total points
ID: 22713132
Hi!
I think you could check objXMLHTTP.getResponseHeader("Content-Type")
If it is xml the header should be "text/xml" and if it is image it should be somthing like "image/jpeg".
0
 

Accepted Solution

by:
Denisdh earned 0 total points
ID: 22719511
I couldn't get response header to print anything for me.

In the end responseText worked.
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

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…

749 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