Link to home
Start Free TrialLog in
Avatar of Chris_Granger
Chris_Granger

asked on

Finding Data from string returned with XMLHTTP Get

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!
Avatar of fritz_the_blank
fritz_the_blank
Flag of United States of America image

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
Hang on, ignore that...

FtB
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
ASKER CERTIFIED SOLUTION
Avatar of fritz_the_blank
fritz_the_blank
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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