Re: Strip HTML



replace < > with
& lt; and & gt;

was just for testing purposes.

"State Troopers" wrote:

Hey.
I want to remove everything BUT <br>

and I was replacing < with < just to test out ".< and .>"

Thanks.

"Douglas J Steele" wrote:

If all you want to do is remove the <BR>, you can use

strOutput = Replace(strOutput, "<BR>", " ")

BTW, why are you using Replace to change < to < and > to >? That does
absolutely nothing, other than taking machine cycles!

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"State Troopers" <StateTroopers@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C77C1BDF-CCF1-4CFE-9D07-A0ABF9A106E4@xxxxxxxxxxxxxxxx
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



.



Relevant Pages

  • Re: Strip HTML
    ... xxyyxx back to. ... 'Ensure that strHTML contains something ... Dim arysplit, i, j, strOutput ... 'Loop through each instance of the array ...
    (microsoft.public.access.formscoding)
  • Re: Strip HTML
    ... Doug Steele, Microsoft Access MVP ... 'Ensure that strHTML contains something ... Dim arysplit, i, j, strOutput ... 'Loop through each instance of the array ...
    (microsoft.public.access.formscoding)
  • Re: Strip HTML
    ... 'Ensure that strHTML contains something ... Dim arysplit, i, j, strOutput ... 'Loop through each instance of the array ... snip out all the text between the start of the string ...
    (microsoft.public.access.formscoding)
  • Re: Strip HTML
    ... strOutput = Join ... Doug Steele, Microsoft Access MVP ... 'Ensure that strHTML contains something ... 'Loop through each instance of the array ...
    (microsoft.public.access.formscoding)
  • Re: Strip HTML
    ... "Douglas J Steele" wrote: ... stripHTML = strOutput ... Doug Steele, Microsoft Access MVP ... strOutput = Join ...
    (microsoft.public.access.formscoding)