Skip to content

How To Remove HTML Markup From Item Styles For Content Query Web Parts in SharePoint 2010

by on March 19, 2012

Add to Item Styles

  1. Open SharePoint Designer
  2. Locate Style Library > XSL Style Sheets > ItemStyles.xsl
  3. Add the code below, the same as any other template

<xsl:template name="removeMarkup">
        <xsl:param name="string" />
            <xsl:when test="contains($string, ‘&lt;’)">
                <xsl:variable name="nextString">
                    <xsl:call-template name="removeMarkup">
                        <xsl:with-param name="string" select="substring-after($string, ‘&gt;’)" />
                <xsl:value-of select="concat(substring-before($string, ‘&lt;’), $nextString)" />
                <xsl:value-of select="$string" />


<xsl:variable name="bodyContent">
    <xsl:call-template name="removeMarkup">
        <xsl:with-param name="string" select="@Description"/>



<xsl:value-of select="$bodyContent"/>

Example: Output String Limited to X Number of Characters

<xsl:variable name="bodyContent">
    <xsl:call-template name="removeMarkup">
        <xsl:with-param name="string" select="@Description"/>



<xsl:value-of select="substring($bodyContent,0,150)" />

To FInd the Internal Field Names

<xsl:for-each select="@*">
    P:<xsl:value-of select="name()" />

NOTE: The Field Name for an events start date is referenced like @EventDate – if you use a name which does not have a corresponding built in field, SharePoint will provide a textbox in the Presentation section of the CQWP Properties which will let you map a field to the @ name

One Comment
  1. JHerschel permalink

    Great tips, thanks!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: