Solved

Finding Data from string returned with XMLHTTP Get

Posted on 2004-08-27
5
259 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

777 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