2016-06-01 34 views
0

我嘗試刪除td有class = feldtyp1且文本內容爲<p>News</p>的每個錶行。Howe刪除帶有文本內容的錶行

我已經到目前爲止,整行被刪除。 現在我仍然需要查詢是否與包含文本內容的類feldtyp1的單元格新聞

有人可以幫助我嗎?我的源XML的

部分

<table class="feldtyp"> 
    <tr> 
     <td class="feldtyp1"><p>Feldtyp</p></td> 
     <td class="feldtyp2"><p>Text</p></td> 
    </tr> 
    <tr> 
     <td class="feldtyp1"><p>News</p></td> 
     <td class="feldtyp2"><p>Text</p></td> 
    </tr> 
</table> 

我現在的XLS刪除所有行

<xsl:output omit-xml-declaration="yes"/> 
    <xsl:template match="node()|@*"> 
     <xsl:copy> 
     <xsl:apply-templates select="node()|@*"/> 
     </xsl:copy> 
    </xsl:template> 
    <xsl:template match="tr|td[@class='feldtyp1']"/> 
    <xsl:template match="tr|td[@class='feldtyp2']"/> 
</xsl:stylesheet> 

期望的結果應該是這樣的

<table class="feldtyp"> 
    <tr> 
     <td class="feldtyp1"><p>Feldtyp</p></td> 
     <td class="feldtyp2"><p>Text</p></td> 
    </tr> 
</table> 

回答

1

我嘗試刪除td有class = feldtyp1和 文本內容爲<p>News</p>的每個錶行。

這並不完全清楚。假設你要刪除包含電池,它的類「feldtyp1」和它(相同細胞)具有<p>News</p>子元素的任何行,你應該做的:

<xsl:template match="tr[td[@class='feldtyp1'and p[.='News']]]"/> 
+0

謝謝,這正是我尋找。 – Olli