Forum Moderators: open
<%
Response.ContentType="text/html"
Set objHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objHTTP.open "GET", [widgets.com...] False
objHTTP.send
f = objHTTP.responseText
response.write f
%>
This works fine to display the returned text to the browser. Rather then send the text to the browser, I need to read the string line-by-line and extract data from specific lines. I've assigned a variable 'f' to objHTTP.responseText and tried to use it with the readline function with no luck.
Error returned for the 'Do While' line: Object required:
I maybe approaching this all wrong. Any help would be very much appreciated. (I can't bother my local ASP guru as she's in the midst of house buying & selling craziness.)
Thanks in advance,
Wayne
The whole (short yet non-functioning) code follows:
<%
Response.ContentType="text/html"
Set objHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objHTTP.open "GET", [widgets.com...]
objHTTP.send
f = objHTTP.responseText
response.write f
ctr=0
Do While f.EndOfStream = False
cur_str= f.ReadLine
If ctr=6 Then
search_str="Widget size: "
size_str=Replace(cur_str, search_str, "")
End If
ctr=ctr + 1
Loop
Set objHTTP = nothing
%>
One way to do this is to move through the string extracting lines by searching for an end of line marker :
currentPos = 1
while ( currentPos <> len( myText) )
' find pos of next end of line marker
myLine = left ( myText, linePos)
currentPos=currentPos+len(myLine)
Wend
Thanks for your response. Now that I know that the responseText is being read as a single string rather than a text stream, I can simply parse the text by using the Instr function since the data follows the same pattern:
Tite: .... Author: .... ISBN....etc.
Thanks for pointing me in the right direction.
Wayne