Solved

Finding Data from string returned with XMLHTTP Get

Posted on 2004-08-27
5
257 Views
Last Modified: 2012-05-05
Hi,

I'm trying to read in currency figures from 2co but the only one which works with this method is AUD. Can someone see what is wrong, the post works and the array is okay. Working sample below:

<%
Checkurl = "http://www.2checkout.com/cgi-bin/rk_buyers/rates.2c"
set objXMLHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP")
objXMLHTTP.Open "GET", Checkurl , False
objXMLHTTP.Send
strReturn = objXMLHTTP.responseText
Set objXMLHTTP = Nothing

aucRate = "-1"
cur_arr = Split(strReturn, " ")
For I = 0 To Ubound(cur_arr)
      If Trim(UCase(cur_arr(I))) = "USD" Then
            aucRate = trim(cur_arr(I+1))
            exit for
      End If
Next

Response.Write aucRate
%>

Thanks!
0
Comment
Question by:Chris_Granger
  • 5
5 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11915758
When I write out the array, I get the below, so something is not what you expect:

AUD
1.4724200000
413310

CAD
1.3610000000
413313

CHF
1.3265500000
413316

DKK
6.4036100000
413309

EUR
0.8611850000
413318

GBP
0.5782370000
413314

HKD
8.1198000000
413317

JPY
114.0210000000
413315

NOK
7.2031000000
413312

NZD
1.5871300000
413324

SEK
7.8624600000
413321

USD
1.0000000000
407666


FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11915772
Hang on, ignore that...

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11915833
Okay, here you go:

<%
Checkurl = "http://www.2checkout.com/cgi-bin/rk_buyers/rates.2c"
set objXMLHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP")
objXMLHTTP.Open "GET", Checkurl , False
objXMLHTTP.Send
strReturn = objXMLHTTP.responseText
Set objXMLHTTP = Nothing

aucRate = "-1"
cur_arr = Split(strReturn, " ")
For i = 0 To Ubound(cur_arr)
   if inStr(1,cur_arr(i),"USD",1)>0  then
      aucRate = cur_arr(i+1)
   end if
Next

Response.Write aucRate
%>


FtB
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 500 total points
ID: 11915926
Oops, I forgot the exit for:

<%
Checkurl = "http://www.2checkout.com/cgi-bin/rk_buyers/rates.2c"
set objXMLHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP")
objXMLHTTP.Open "GET", Checkurl , False
objXMLHTTP.Send
strReturn = objXMLHTTP.responseText
Set objXMLHTTP = Nothing

aucRate = "-1"
cur_arr = Split(strReturn, " ")
For i = 0 To Ubound(cur_arr)
   if inStr(1,cur_arr(i),"USD",1)>0  then
     aucRate = cur_arr(i+1)
     exit for
   end if
Next

Response.Write aucRate
%>
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11916016
The reason why your code didn't work is that the array value was not USD, but rather, <br> a carriage return and then the USD.

FtB
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

15 Experts available now in Live!

Get 1:1 Help Now