开发者

Strip HTML-like characters (not markup) from XML with XSLT?

Is there a way to strip all HTML from XML with XSLT,

like PHP strip_tags() ?

I want to keep the text, but remove all formatting, etc.

This will be taking place before truncating.

   Hey Kurt, <br> I'd like to suggest that we start inventor开发者_运维问答ying a system feature list at a <br> high-level. From there, we would define the requirements of the features. <br> Next, design to the requirements, develop, test, deploy..wash, rinse, and <br> repeat.. <br> I.E. <br> Event Calendar <br> - Requirement No. 1 <br> - Requirement No. 2


I found this solution on various places in the internet using Google:

Some examples of my research:
here, here, here

<!-- Calling the template that removes tag -->
<xsl:call-template name="remove-html">
    <xsl:with-param name="text" select="{HtmlBody}"/>
</xsl:call-template>

<!-- This will remove the tag -->
<xsl:template name="remove-html">
    <xsl:param name="text"/>
    <xsl:choose>
        <xsl:when test="contains($text, '&lt;')">
            <xsl:value-of select="substring-before($text, '&lt;')"/>
            <xsl:call-template name="remove-html">
                    <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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜