VB6 过滤HTML


' 过滤HTML字符替换为文字
Private   Function  ReplaceToText(ByVal Html  As   String )
    
Dim  i  As   Integer
    
Dim  CurPosBefore  As   Long
    
Dim  CurPosEnd  As   Long
    
Dim  ReplaceTextTMP  As   String
    
Dim  ReplaceText  As   String     ' 替换为该字符
    
    
Do
        ReplaceText 
=   ""
        CurPosBefore 
=   InStr ( 1 , Html,  " < " )
        
If  CurPosBefore  <>   0   Then
            
' found < text
            CurPosEnd  =   InStr (CurPosBefore, Html,  " > " )
            
If  CurPosEnd  <>   0   Then
                
' found > text
                ReplaceTextTMP  =   Mid (Html, CurPosBefore, CurPosEnd  -  CurPosBefore  +   1 )
                
If   Len (ReplaceTextTMP)  >   3   Then
                    
If   Left (ReplaceTextTMP,  4 =   " <img "   Then
                        ReplaceText 
=   " [图象] "
                    
End   If
                
End   If
                Html 
=   Replace (Html, ReplaceTextTMP, ReplaceText)
            
End   If
        
End   If
    
Loop   While   InStr ( 1 , Html,  " < " <>   0
    Html 
=   Replace (Html,  " &nbsp; " "   " )
    ReplaceToText 
=  Html
End Function

你可能感兴趣的:(html)