p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   XSLT (http://p2p.wrox.com/xslt-86/)
-   -   strip html tags with xslt (http://p2p.wrox.com/xslt/54014-strip-html-tags-xslt.html)

smiter February 13th, 2007 04:04 PM

strip html tags with xslt
 
I am busy with a website where customers can edit there profile. They can also use some kind of editor which produces html tags that will be wrapped around the text.

The xml looks something like this:

<Profile>
<p>This is a <b>profile</b> text blablalbla</p><br/>
</Profile>

Now I am creating some kind of master page with links to detail pages. On the detailpages the html has to be output as html code (using disable output-escaping).

On the masterpage I just want this as output:
"This is a profile text blablalbla"

So all the html tags must be ignored or stripped out.


Is this possible with xslt?

Thanks in advance,

M. Smit


smiter February 13th, 2007 04:24 PM

Problem solved:

Found this template and works fine...

<xsl:template name="strip-tags">
    <xsl:param name="text"/>
    <xsl:choose>
        <xsl:when test="contains($text, '&lt;')">
            <xsl:value-of select="substring-before($text, '&lt;')"/>
            <xsl:call-template name="strip-tags">
                    <xsl:with-param name="text" select="substring-after($text, '&gt;')"/>
            </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="$text"/>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

Use it this way:

<xsl:call-template name="strip-tags">
    <xsl:with-param name="text" select="Profile"/>
</xsl:call-template>




mhkay February 13th, 2007 05:55 PM

Sure, just do

<xsl:value-of select="Profile"/>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference

Manikandan June 19th, 2012 07:23 AM

I want remove <p> tags from sitecore rich text editor
 
I want remove <p> tags from sitecore rich text editor in xslt.

Please help on this.

Thanks in advance.


-Mani

mhkay June 19th, 2012 08:34 AM

If this is an XSLT question, please show us a sample input document and the output you want from it. Please also explain what you have tried and where you got stuck; this helps us to know how much explanation we need to give in reply. Please also don't assume that anyone on this forum knows anything about the sitecore rich text editor. Finally, please start a new question on a new thread, rather than replying to a thread that is more than five years old.


All times are GMT -4. The time now is 04:45 AM.

Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.