User Rajesh Roshan ( posted:

Hi All,
I've a small problem with the parsing of HTML Table
function below:
If the same row and column has number of links,i can
go to only 1st link ,but how to go to 2nd link
residing in the same location(same row,column)?
Declare Function FindTextinTable(tableIn as String,row
as Integer,col as Integer) as String

Sub Main
Dim Result as Integer
Dim linkText as String
Dim tableHTML as String

Result = SQAGetPropertyasString
("Type=HTMLTable;Index=11","innerHTML",tableHTM L)

linkText = FindTextinTable(tableHTML,2,5)
msgbox linkText

End Sub

Function FindTextinTable(tableIn as String,row as
Integer,col as Integer) as String
'Variable Declaration
Dim HTMLLen as Integer 'length of HTML
Dim pos as Integer 'position
Dim endpos as Integer 'end position
Dim posnbsp as Integer 'position of
Dim x as Integer 'counter
Dim currentChar as String 'current character
at the position
Dim tempString as String 'temporary String
for manipulation

'Variable Initialization
pos = 1
HTMLLen = Len(tableIn)

'Goto desired row
For x = 1 to row
pos = InStr(pos+1,tableIn,"<TR",1)
next x

'Goto desired column, if the row was found
If pos > 0 Then
For x = 1 to col
pos = InStr(pos+1,tableIn,"<TD",1)
next x
End If

'If the row and column were found start parsing any
' HTML tags IE: <SPAN>, <FONT>, etc..
If pos > 0 Then
'look for the end of a tag
pos = InStr(pos+1,tableIn,">",1) + 1

'get the next character after end of the tag
currentChar = Mid$(tableIn,pos,1)

'if the character is not text or is the start
of another tag
' keep on looking until we find the text
Do While (Asc(currentChar) < 33 or
Asc(currentChar) = 60)
pos = InStr(pos+1,tableIn,">",1) +1
currentChar = Mid$(tableIn,pos,1)

'get the position of the next start tag which
indicates the end of the text
endpos = InStr(pos,tableIn,"<",1)

'Find how long the text portion is
HTMLLen = endpos - pos

'Find the string we are looking for
tempString = Mid$(tableIn,pos,HTMLLen)

'Look for any non-breaking spaces (nbsp)
posnbsp = InStr(1,tempString,"",1)

'If we find one then replace it with a normal
' and loop until there are none left
Do While posnbsp > 0
'since the Mid statement doesn't function
properly use
' the Mid function to pick around the
tempString = Mid$(tempString,1,posnbsp-1)
+ " " + _

posnbsp = InStr(1,tempString,"",1)

'return the text we found
FindTextinTable = Trim$(tempString)
'if row and/or column were not found then
return a blank
FindTextinTable = ""
End If

End Function
I appreciate your help.