Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 20th, 2004, 12:11 PM
Registered User
 
Join Date: Feb 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Strip HTML with ASP Question

Hello,

I am trying to strip all the html tags, including   as well as all end of line characters so that whats left is all on one line. I have got it working for just the html tags but cant for the life of me get it to clean the   or end of line characters. Here's what I have so far. Any suggestions?

Function StripHTMLTag(ByVal sText)
   StripHTMLTag = ""
   fFound = False
   Do While InStr(sText, "<")
      fFound = True
      StripHTMLTag = StripHTMLTag & " " & Left(sText, InStr(sText, "<")-1)
      sText = MID(sText, InStr(sText, ">") + 1)
   Loop
   Do While InStr(sText, "&nbsp;")
      fFound = True
      StripHTMLTag = StripHTMLTag & " " & Left(sText, InStr(sText, "&nbsp;")-1)
      sText = MID(sText, InStr(sText, "&nbsp;") + 1)
   Loop
   StripHTMLTag = StripHTMLTag & sText
   If Not fFound Then StripHTMLTag = sText
End Function

 
Old January 17th, 2005, 08:15 AM
Registered User
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here I think you have the response to your question, i hope that helps you. You were very near.
Function StripHTMLTag(ByVal sText)
   StripHTMLTag = ""
   fFound = False
   Do While InStr(sText, "<")
      fFound = True
      StripHTMLTag = StripHTMLTag & " " & Left(sText, InStr(sText, "<")-1)
      sText = MID(sText, InStr(sText, ">") + 1)
   Loop
   sText = StripHTMLTag & sText
       StripHTMLTag = ""
   Do While InStr(sText, " ")
      fFound = True
      StripHTMLTag = StripHTMLTag & " " & Left(sText, InStr(sText, " ")-1)
      sText = MID(sText, InStr(sText, " ") + 6)
   Loop
   StripHTMLTag = StripHTMLTag & sText
   If Not fFound Then StripHTMLTag = sText
End Function






Similar Threads
Thread Thread Starter Forum Replies Last Post
strip html tags with xslt smiter XSLT 4 June 19th, 2012 08:34 AM
Two HTML files Question bonekrusher XSLT 2 August 10th, 2006 02:04 PM
strip html from spider script results mcalcagno PHP How-To 0 January 31st, 2005 09:14 AM
very simple HTML question nusrati HTML Code Clinic 11 July 13th, 2004 07:58 PM
strip html tags & PHP trangd Beginning PHP 6 October 21st, 2003 10:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.