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:

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

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: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:value-of select="$text"/>

Use it this way:

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

mhkay February 13th, 2007 05:55 PM

Sure, just do

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

Michael Kay
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.


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 09:14 PM.

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