Here we will see how to remove HTML using XSLT in Data form Web part to Control the Rich text field Content.The Following XSL template shows how to remove the tags from the HTML so that you are only left with the text within the HTML to handle the Rich text field Content Value.<xsl:template name="deleteHtmlTags"><xsl:param name="html"/><xsl:choose><xsl:when test="contains($html, '<')"><xsl:value-of select="substring-before($html, '<')"/><!-- Recurse through HTML --><xsl:call-template name="deleteHtmlTags"><xsl:with-param name="html" select="substring-after($html, '>')"/></xsl:call-template></xsl:when><xsl:otherwise><xsl:value-of select="$html"/></xsl:otherwise></xsl:choose></xsl:template>To use the template you call it passing the HTML as a paramter... to delete the HTML tags.<xsl:variable name="onlyText"><xsl:call-template name=" deleteHtmlTags"><xsl:with-param name="html" select="@Body" /></xsl:call-template></xsl:variable>Before Using the Variable it will display all the content like as follows :Then using this variable to display only text with Read more Option to view the<div class="ms-PostBody"> <div ><xsl:value-of select="substring($onlyText, 0, 360)" /><div align="right" style="color:red;text-decoration:none"><a href="{$HttpVDir}/Lists/Posts/Post.aspx?ID={@ID}"><font color="red">Read more</font></a>...</div></div></div>After you Implementing this, it will be like as follows Remove person (Author) hyper link from Data view Webpart using XSLTHere we will see how you can eliminate the hyperlink, when displaying the column @Author (posted by) in a Data View Web Part (DVWP) SharePoint displays a link to the UserDisp.aspx page. If you don't want to have the link just extract the Person's name from the column HTML generated code.Just you have to replace with<xsl:value-of disable-output-escaping="yes" select="@Author"/>By:<xsl:value-of disable-output-escaping="yes" select="substring-after(substring-before(substring-after(@Author, 'ID='), '<'), '>')"/>In some cases Author format is like xxxxxxx(xxx,IND) / xxxxxxx(xxx,USA). If you want to replace the Author from this formatYou can use the below one.<xsl:value-of disable-output-escaping="yes" select="substring-after(substring-before(substring-after(@Author, 'ID='), '('), '>')"/>After applying the changes, it will show only Author name without hyperlink.Enjoy!!!
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: