Remove XML Node text using XSLT -
i need modify xml document xslt. need remove node name xml document.
example:
<link ref="www.facebook.com"> <c type="hyperlink">www.facebook.com<c> </link> i need convert xml follows (remove <c> node , attribute form xml),
<link ref="www.facebook.com"> www.facebook.com </link> i tried in many ways none of worked out well. suggestions how can ?
here's 1 way:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/> <xsl:strip-space elements="*"/> <!-- identity transform --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="c"> <xsl:apply-templates/> </xsl:template> </xsl:stylesheet> here's another:
<xsl:template match="link"> <xsl:copy> <xsl:copy-of select="@* | c/text()"/> </xsl:copy> </xsl:template>
Comments
Post a Comment