[英]Extract text inside HTML tags using XSLT
I have an XML file that has some CDATA with html tags. 我有一个带有一些带有html标签的CDATA的XML文件。 Example:
例:
<TextElement>
<Data>
<![CDATA[ <h2>My Header Text</h2> ]]>
</Data>
</TextElement>
I need to be able to display "My Header Text" without the H2 tag. 我需要能够显示不带H2标签的“我的标题文本”。
Thank you! 谢谢!
Using 使用
<xsl:param name="start-tag"><![CDATA[<h2>]]></xsl:param>
<xsl:param name="end-tag"><![CDATA[</h2>]]></xsl:param>
and then a substring-after(substring-before
combination 然后是
substring-after(substring-before
组合
<xsl:template match="Data">
<xsl:value-of select="substring-before(substring-after(., $start-tag), $end-tag)"/>
</xsl:template>
should do. 应该做。 http://xsltransform.net/naZXpY6 .
http://xsltransform.net/naZXpY6 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.