G
Guest
Hi there.
I am currently working on a database/program that will take a certain html
page and store the strings on the page into a table, which will then be used
in reports/queries.
I have started with stripping the HTML tags off the page first. The function
works very well.
But, my problem is that I am not sure how I would illiminate the function
from removing "<br>" .
Here is the function:
'Ensure that strHTML contains something
If Len(strHTML) = 0 Then
stripHTML = strHTML
Exit Function
End If
Dim arysplit, i, j, strOutput
arysplit = Split(strHTML, "<")
'Assuming strHTML is nonempty, we want to start iterating
'from the 2nd array postition
If Len(arysplit(0)) > 0 Then j = 1 Else j = 0
'Loop through each instance of the array
For i = j To UBound(arysplit)
'Do we find a matching > sign?
If InStr(arysplit(i), ">") Then
'If so, snip out all the text between the start of the string
'and the > sign
'IF statement to NOT remove <br> tags.
arysplit(i) = Mid(arysplit(i), InStr(arysplit(i), ">") + 1)
Else
'Ah, the < was was nonmatching
arysplit(i) = "<" & arysplit(i)
End If
Next
'Rejoin the array into a single string
strOutput = Join(arysplit, "")
'Snip out the first <
strOutput = Mid(strOutput, 2 - j)
'Convert < and > to < and >
strOutput = Replace(strOutput, ">", ">")
strOutput = Replace(strOutput, "<", "<")
strOutput = Replace(strOutput, "–", "<")
stripHTML = strOutput
Thanks.
-State
I am currently working on a database/program that will take a certain html
page and store the strings on the page into a table, which will then be used
in reports/queries.
I have started with stripping the HTML tags off the page first. The function
works very well.
But, my problem is that I am not sure how I would illiminate the function
from removing "<br>" .
Here is the function:
'Ensure that strHTML contains something
If Len(strHTML) = 0 Then
stripHTML = strHTML
Exit Function
End If
Dim arysplit, i, j, strOutput
arysplit = Split(strHTML, "<")
'Assuming strHTML is nonempty, we want to start iterating
'from the 2nd array postition
If Len(arysplit(0)) > 0 Then j = 1 Else j = 0
'Loop through each instance of the array
For i = j To UBound(arysplit)
'Do we find a matching > sign?
If InStr(arysplit(i), ">") Then
'If so, snip out all the text between the start of the string
'and the > sign
'IF statement to NOT remove <br> tags.
arysplit(i) = Mid(arysplit(i), InStr(arysplit(i), ">") + 1)
Else
'Ah, the < was was nonmatching
arysplit(i) = "<" & arysplit(i)
End If
Next
'Rejoin the array into a single string
strOutput = Join(arysplit, "")
'Snip out the first <
strOutput = Mid(strOutput, 2 - j)
'Convert < and > to < and >
strOutput = Replace(strOutput, ">", ">")
strOutput = Replace(strOutput, "<", "<")
strOutput = Replace(strOutput, "–", "<")
stripHTML = strOutput
Thanks.
-State