首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

在SQL中存储了用网页编辑器写的文本,里面的内容有一部分html代码,如何把html代码去掉,还能保持原来的格式?

2012-01-06 
在SQL中存储了用网页编辑器写的文本,里面的内容有一部分html代码,怎么把html代码去掉,还能保持原来的格式?

在SQL中存储了用网页编辑器写的文本,里面的内容有一部分html代码,怎么把html代码去掉,还能保持原来的格式??
在SQL中存储了用网页编辑器写的文本,里面的内容有一部分html代码,怎么把html代码去掉,还能保持原来的格式??

例:
姓名: <br> 性别: <br> 年龄: <br>
怎么把上面的html代码去掉还能保持换行的格式??
姓名:
性别:
年龄:

[解决办法]
Buf = Replace(Buf, " <br> ", "Chr(13) ")
[解决办法]
Form1.Caption = "正在去掉 <head> 部分... "
' "去掉 <head> 部分
Do While InStr(1, LCase(text1.text), " </head> ") <> 0

Text3.SelStart = 0
Text3.SelLength = InStr(1, LCase(text1.text), " </head> ") + 6
Text3.SelText = " "

Loop
Form1.Caption = "正在去掉 <script> 部分... "
'去掉 <script> 部分
Do While InStr(1, LCase(text1.text), " </script> ") <> 0

Text3.SelStart = InStr(1, LCase(text1.text), " <script ") - 1
Text3.SelLength = InStr(1, LCase(text1.text), " </script> ") - Text3.SelStart + 9
Text3.SelText = " "

Loop
Form1.Caption = "正在转换 <br> 为换行符... "
'转换 <br> 为换行符
Do While InStr(1, LCase(text1.text), " <br> ") <> 0

Text3.SelStart = InStr(1, LCase(text1.text), " <br> ") - 1
Text3.SelLength = 4
Text3.SelText = " " + vbCrLf

Loop
Form1.Caption = "正在转换 <br/> 为换行符... "
'转换 <br> 为换行符
Do While InStr(1, LCase(text1.text), " <br/> ") <> 0

Text3.SelStart = InStr(1, LCase(text1.text), " <br/> ") - 1
Text3.SelLength = 5
Text3.SelText = " " + vbCrLf

Loop
Form1.Caption = "正在转换 <p> </p> 为换行符... "
'转换 </p> 为换行符
Do While InStr(1, LCase(text1.text), " </p> ") <> 0

Text3.SelStart = InStr(1, LCase(text1.text), " </p> ") - 1
Text3.SelLength = 4
Text3.SelText = " " + vbCrLf

Loop


Form1.Caption = "正在删除Html标记... "
'去掉其它的Html标记
Do While InStr(1, LCase(text1.text), " < ") <> 0 And InStr(1, LCase(text1.text), "> ") <> 0

Text3.SelStart = InStr(1, LCase(text1.text), " < ") - 1
Text3.SelLength = InStr(1, LCase(text1.text), "> ") - Text3.SelStart
Text3.SelText = " "

Loop


Form1.Caption = "正在转换空格符... "
' "转换 " "为 " "
Do While InStr(1, LCase(text1.text), " ") <> 0

Text3.SelStart = InStr(1, LCase(text1.text), " ") - 1
Text3.SelLength = 6
Text3.SelText = " "

Loop

热点排行