Hakoo Desai
Hakoo Desai

Reputation: 185

How to retrive information from another website to my website in classic asp

I want to retrive Product Status from other website to my website. For that I am using this code.

Dim xml
set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", "http://www.midwayusa.com/Product/"&sCode  , false
xml.Send

Dim strRetrive,strtCnt,endCnt,strStatus,strShippingMessage,a
strRetrive=xml.responseText
strtCnt=InStr(strRetrive,"productStatus")
strtCnt=Instr(strtCnt,strRetrive,">")
endCnt=Instr(strtCnt,strRetrive,"<")
strStatus = (mid(strRetrive,(strtCnt+1),(endCnt-(strtCnt+1))))
getStatusFromMidway = trim(a)

This gives me status but lots of spaces and unwanted characters. I tried trim function, but that is not removing spaces at all. Afterwards, I tried Replace(vari," ",""), but it removes all spaces from string which is not good..

Now, I am thinking to use XML DOM, or similar functionality, Can anyone help me for that?

Upvotes: 0

Views: 103

Answers (1)

johna
johna

Reputation: 10752

Replace your Trim with this function (SuperTrim) that removes all leading and trailing non-word characters.

eg. Add this function and change getStatusFromMidway = trim(a) to getStatusFromMidway = SuperTrim(a)

Function SuperTrim(input)
    Dim regex, result
    Set regex = New RegExp
    regex.Pattern = "^\W+"
    regex.IgnoreCase = True
    regex.Global = True
    result = regex.Replace(input, "")
    regex.Pattern = "\W+$"
    result = regex.Replace(result, "")
    Set regex = nothing
    SuperTrim = result
End Function

Upvotes: 1

Related Questions