Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
691 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
  • 2
4 Comments
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 1100 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 900 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

886 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