Function to clean html

1

How to do a function that wipes HTML? I have a field that comes from a WS and I need, before displaying on the page, to clean the HTML.

They sent me this:

String result = Regex.Replace(htmlDocument, @"<[^>]*>", String.Empty);

I need to put this code in a jquery function, right here, and this.ShortDescription is the guy I want to clean. How do I do it?

str += '<p>' + this.ShortDescription + '</p>';

The above code is part of a jQuery function.

    
asked by anonymous 27.03.2014 / 20:07

2 answers

3

In javascript you can use:

document.body.innerHTML = '';
    
27.03.2014 / 20:14
0

I use the following vb.net code:

Public Function limpaHTML_Recursiva(ByVal sTexto As String, ByVal j As Integer) As String
    If j = 0 Then
        Return sTexto
    End If
    Dim i As Integer = 0
    i = InStr(sTexto, "<")
    j = InStr(sTexto, ">")
    If i > 0 Then
        i -= 1
    End If
    sTexto = Left(sTexto, i) & Right(sTexto, sTexto.Length - j)
    Return (limpaHTML_Recursiva(sTexto, j))
End Function

Call with: sTexto = limpaHTML_Recursiva(sTexto, 1)

    
27.03.2014 / 21:30