codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  ASPTear  Archive Import (Johannes) at 04:48 on Thursday, March 06, 2003
 

Hello, I am struggling with the following code, which is supposed to return a HTML page, parsed from another server, first numbering the cells of a table and secondly grabing the values into my html page.
Please can anyone help me on this one:
1. Where and how do I declare which Url I want to retrieve data from?
2. Where is the output in the function: I cant see any response.write?

Thank you so much! And please note I am an absolute beginner- so please make your elaborations as easy as possible. Thank you



<%
'extract.asp (c) 2000 Thomas Winningham - use freely!

Function GetCell(cellnumber, extracturl)
'Variables: Cellnumber: Number of the cell to get data from
'ExtractURL: complete url that contains the cells and data
'Returns a string of the cells data (including html)

'Use the SOFTWING.AspTear component to get the HTML (but any
'will do... just rewrite this part) connection is including in
'Function for purpose of being self-contained
Const Request_POST = 1
Const Request_GET = 2

Set xObj = Server.CreateObject("SOFTWING.AspTear")
strRetVal = xObj.Retrieve(extracturl,Request_GET,"","","")
set xobj = nothing

i = 1 ' HTML Text Location Start
q = 1 ' Cell Number Start

' Loop until we have processed the cell we're looking for
Do until q > cellnumber
' Look for <TD the start of a cell
i = InStr(i, UCase(strRetVal), "<TD")

' Find the location of the end of the <TD tag
r = InStr(i, strRetVal, ">")

' Let the next loop start looking after this <TD tag we found
i = r + 1

' increase the count of which cell we're at
q = q + 1
Loop

' The start of our cell text is right after the last found tag
StartCellText = i

' Now... to find the end of this cell's text, we look for either <TABLE
' or <TD - whichever comes first (but we have to check if they exist or not)
' We don't include nested tables in the cell data because those tables have
' cells of their own.
If (InStr(r, UCase(strRetVal), "<TABLE") > 0) AND _
(InStr(r, UCase(strRetVal), "<TABLE") < _
InStr(r, UCase(strRetVal), "</TD>")) then
ThisCellText = mid(strRetVal, StartCellText, _
InStr(r, UCase(strRetVal),"<TABLE")- StartCellText )
Else
ThisCellText = mid(strRetVal, StartCellText, _
InStr(r, UCase(strRetVal), "</TD>")- StartCellText )
End If

GetCell = ThisCellText
End Function



Function NumberCells(extracturl)
'Variables: ExtractUrl: The URL (eg http://www.cnn.com) to number
'returns a string of the entire HTML document with numbers at the beginning
'of each cell

'Use the SOFTWING.AspTear component to get the HTML (but any will do...
'just rewrite this part)
'connection is including in Function for purpose of being self-contained
Const Request_POST = 1
Const Request_GET = 2

Set xObj = Server.CreateObject("SOFTWING.AspTear")
strRetVal = xObj.Retrieve(extracturl,Request_GET,"","","")
set xobj = nothing

i = 1 ' HTML Text Location Start
q = 1 ' Cell Number Start

' So long as <TD cells exist- number them
Do while InStr(i, UCase(strRetVal), "<TD") > 0
' find next <TD
i = InStr(i, UCase(strRetVal), "<TD")

' fomd the end of the <TD
r = InStr(i, strRetVal, ">")
strRetVal = left(strRetVal, r) & q & _
right(strRetVal, len(strRetVal) - r)

'Number the cells: the string equals all the html we've check,
'our cell number, and then the html we've yet to check
' Let the next loop start looking after this <TD tag we found
i = r + 1

' increase the count of which cell we're at
q = q + 1
Loop

NumberCells = strRetVal
End Function
%>








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: huffman encoding and decoding in C++...
•  Perl One Liner: Replace {(
•  Re: html including php, accessing the functions
•  Something like an INI editor or a DelimitedText-Editor
•  Error Deleting File or Folder
•  Re: How can use ASP.NET RegularExpressionValidator for alphanumeric 10 digit input
•  Re: drop-down menu selected value
•  Re: how to convert wav file to text file
•  Re: Add an OnChange event to an ASP page


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2009