Solved

Vb.net/Asp.net remove Html tags

Posted on 2010-09-17
3
664 Views
Last Modified: 2012-05-10
I need show part of text stored in a database field. But text is stored in html format. Need remove html tags to show as plain text
0
Comment
Question by:rflorencio
3 Comments
 
LVL 7

Accepted Solution

by:
klakkas earned 250 total points
ID: 33700016
Use this:
'Remove all tags

    Private Function RemoveTags(ByVal inp As String) As String

        Dim res As String



        res = inp.Substring(0, inp.IndexOf("<"))

        inp = inp.Substring(inp.IndexOf("<"))



        Do While inp.IndexOf("<") >= 0

            inp = inp.Substring(inp.IndexOf(">") + 1)

            If inp.IndexOf("<") >= 0 Then

                res &= inp.Substring(0, inp.IndexOf("<"))

            Else

                res &= inp

            End If

        Loop



        res = res.Replace("&nbsp;", " ")

        res = res.Replace(vbCr, " ")

        res = res.Replace(vbLf, " ")



        Do While res.IndexOf("  ") >= 0

            res = res.Replace("  ", " ")

        Loop

        Return res



    End Function

Open in new window

0
 
LVL 10

Assisted Solution

by:WhiteMeat
WhiteMeat earned 250 total points
ID: 33700265
regular expressions

Public Shared Function StripHtmlTags(ByVal text As String) As String

Return System.Text.RegularExpressions.Regex.Replace(text, "<(.|\n)*?>", String.Empty)

End Function

Open in new window

0
 

Author Comment

by:rflorencio
ID: 33723797
i can´t close the question, but i not know why
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now