Solved

Finding Data from string returned with XMLHTTP Get

Posted on 2004-08-27
5
260 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
[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
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Passing Parameter to Stored Procedure 4 32
Button function on table is in trouble 3 35
Date on a table 16 35
Adding 1 the value of input "text" every 3 seconds 5 33
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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 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