scrubbing comments

4 posts, 0 answers
  1. Albert Shenker
    Albert Shenker avatar
    579 posts
    Member since:
    Mar 2004

    Posted 20 May 2013 Link to this post

    Can anyone suggest a way of scrubbing the comments content created by rad editor without loading the content in Rad Editor and using the built-in Remove All toolbar button? Ideally this would be done server-side on some piece of content.
  2. Elliott
    Elliott avatar
    392 posts
    Member since:
    May 2010

    Posted 20 May 2013 Link to this post

    yes
    pump the content into an XDcoument (add a <root> and a </root> to the front and back, which you will remove at the end)
    use XPath navigator to locate nodes that are comments - I looked and it seemed that they are
    <span RadEditor: title='actual comment'> text being commented on</span>
    replace the span node with the text being commented on (or the <span...> with just a <span> - remove the attributes?
    or you could do it with string replaces
  3. Albert Shenker
    Albert Shenker avatar
    579 posts
    Member since:
    Mar 2004

    Posted 21 May 2013 Link to this post

    unfortunately my xml processing skills are not that sharp. I wonder if Telerik has an example of doing this. Surely they must do something similar in order to remove the comments when users click on the "Remove Al comments" button.
  4. Elliott
    Elliott avatar
    392 posts
    Member since:
    May 2010

    Posted 22 May 2013 Link to this post

    this should get you started
    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="RadEditorComments.aspx.vb" Inherits="RadEditorComments" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <title></title>
    </head>
    <body>
    <form id="form1" runat="server">
    <telerik:RadAjaxManager ID="raManager" runat="server" />
    <telerik:RadscriptManager ID="rsManager" runat="server" />
    <table>
    <tr>
    <td>
        <telerik:RadEditor ID="rdEditor" EnableComments="true" runat="server">
        </telerik:RadEditor>
    </td>
    </tr>
    <tr>
    <td align="right">
        <telerik:RadButton ID="rbGo" Text="Go" runat="server" Height="22px" />
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    Imports System.Xml
     
    Partial Class RadEditorComments
        Inherits System.Web.UI.Page
     
        Protected Sub rbGo_Click(sender As Object, e As System.EventArgs) Handles rbGo.Click
            Dim theBody As XmlDocument
            Dim someNodes As XmlNodeList = Nothing
            Dim ANode As XmlNode = Nothing
            Dim sb As StringBuilder = Nothing
     
            sb = New StringBuilder("<root>")
            sb.Append(rdEditor.Content)
            sb.Append("</root>")
            theBody = New XmlDocument
            theBody.LoadXml(sb.ToString)
            someNodes = theBody.SelectNodes("/root/span[@title]")
            For Each ANode In someNodes
                ANode.Attributes.RemoveAll()
            Next
            sb = New StringBuilder(theBody.OuterXml)
           ' remove the <root> and </root>
            sb.Remove(0, 6)
            sb.Remove(sb.Length - 7, 7)
        End Sub

    use sb.tostring as the body of your email
    this may need tweaking to accommodate styling
Back to Top