Solved

Vb.net/Asp.net remove Html tags

Posted on 2010-09-17
3
669 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ModalPopup  question 22 39
Need help with a query 3 39
Calculating percentage 2 31
Blending HTML output from R Studio into a ASP.Net/C# project 4 23
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 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