Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide HTML Tags in report Comments field on SQL Report 2005

Status
Not open for further replies.

MoeSSRS

IS-IT--Management
Mar 26, 2009
23
US
I created a report and I have a comment field box showing bunch of HTML Tags and I dont want to show on my report. I wrote an expression to hide this as follows but this is to hide only one tag but I want to hide multiple tags not to show. Can anybody let me know what to add in my expression so that I could hide multiple html tags. Thanks and appreciate your quick response. See example of my expressions working fine with only one and also the comments box on my reports showing html tages such as <P>, </P>, &nbsp;<BR> etc. Talk to you later.

Replace(Fields!COMMENTS.Value,"</P>","")



Work Order Instructions:
<P>NEED TO RAISE BOX AND COVER AND INSTALL NEW ONE.</P> <P>MATERIALS:</P> <P>99-19&nbsp;&nbsp;&nbsp; DBL/BOX&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp; 99</P> <P>99-10A&nbsp; DBL/LID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp; 99</P>

 
Code:
CREATE FUNCTION [dbo].[udf_StripHTML]
    (@HTMLText VARCHAR(8000))
RETURNS VARCHAR(8000)
            AS
    BEGIN
    DECLARE @Start  INT
    DECLARE @End    INT
    DECLARE @Length INT
        SET @Start = CHARINDEX('<',@HTMLText)
        SET @End = CHARINDEX('>',@HTMLText,CHARINDEX('<',@HTMLText))
        SET @Length = (@End - @Start) + 1
    WHILE @Start > 0 
                AND @End > 0 
            AND @Length > 0
        BEGIN
        SET @HTMLText = STUFF(@HTMLText,@Start,@Length,'')
        SET @Start = CHARINDEX('<',@HTMLText)
        SET @End = CHARINDEX('>',@HTMLText,CHARINDEX('<',@HTMLText))
        SET @Length = (@End - @Start) + 1
        END
    RETURN Replace(LTRIM(RTRIM(@HTMLText)),'&nbsp;',' ')
    END


GO

I use this function...

Code:
select [dbo].[udf_StripHTML](textFieldwithHTML) TextOnly
From table
 
Thanks for the all the information. But I found the answer on how to hide multiple Html Tages if you need to. Here is teh expression I put in my field text box this expression it took it out all the html tags such as(<P>,<\P>,<BR>,;,&nbsp) that I dont need it. Here is the expressions that works for me. Let me know if anyone has any questions.

=Replace(Replace(Replace(Replace(Replace(Fields!COMMENTS.Value,"</P>",""),"<P>",""),"&nbsp",""),"<BR>",""),";","")

 
Moe the expression you posted will only hide <P><BR> and non-breaking spaces. The function that checkai posted will remove all HTML tags from the text no matter the tag.

Denny
MVP
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / SQL 2005 BI / SQL 2008 DBA / SQL 2008 DBD / SQL 2008 BI / MWSS 3.0: Configuration / MOSS 2007: Configuration)
MCITP (SQL 2005 DBA / SQL 2008 DBA / SQL 2005 DBD / SQL 2008 DBD / SQL 2005 BI / SQL 2008 BI)

My Blog
 
Right now that's all I need. Later on If I need I will use the script given. Thanks and appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top