XSLT如何删除<p>元素中的<span>元素?

时间:2016-07-28 17:24:57

标签: html xml xslt

假设我有一个带有段落块的文档,如下所示:

<p>
One morning, when Gregor Samsa woke from troubled dreams, he found himself
transformed in his bed into a horrible vermin. He lay on his armour-like 
back, and if he lifted his head a little he could see his brown belly, 
slightly domed and divided by arches into stiff sections. The bedding was  
hardly able to cover it and seemed ready to slide off any moment.  
<span style="background-color:rgb(255, 255, 255); color:rgb(102, 102, 102)">
    <span next="added-diff-1" changeId="added-diff-0" previous="first-diff" id="added-diff-0" class="diff-html-added">
    Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts.
    </span>
</span>
His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked.
</p>

是否可以使用XSLT读取 p 元素但排除 span 标记以及嵌套在段落内的span标记之间的内容?我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

使用身份转换模板和模板<xsl:template match="p//span"/>

相关问题