?
Solved

Finding Data from string returned with XMLHTTP Get

Posted on 2004-08-27
5
Medium Priority
?
262 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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 informatio…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

762 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