如何使用 xslt 删除特定元素但不删除其中的文本 [英] how to remove specific elements but not the text inside it using xslt
本文介绍了如何使用 xslt 删除特定元素但不删除其中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的输入xml
<para>
<a><b>this is a text</b></a>
</para>
这是我的预期输出
<para>
this is a text
</para>
如何只删除所有a"标签和b"标签,并且使用 xslt 不会影响文本,谢谢
how can i delete all the "a" tags and the "b" tags only and the text will not be affected using xslt thanks
推荐答案
<xsl:template match="//para">
<xsl:copy>
<xsl:value-of select="."></xsl:value-of>
</xsl:copy>
</xsl:template>
(或避免来自其他子元素的空白:
(or to avoid white space from other child elements:
<xsl:template match="//para">
<xsl:copy>
<xsl:value-of select="./*/*/text()"></xsl:value-of>
</xsl:copy>
</xsl:template>
这篇关于如何使用 xslt 删除特定元素但不删除其中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文