我已經查找了有關stackflow的解決方案,但它們都不適用於我。這是我的問題。可以說我有以下文字:在XSLT期間保留某些html標記
來源:
<greatgrandparent>
<grandparent>
<parent>
<sibling>
Hey, im the sibling .
</sibling>
<description>
$300$ <br/> $250 <br/> $200! <br/> <p> Yes, that is right! <br/> You can own a ps3 for only $200 </p>
</description>
</parent>
<parent>
... (SAME FORMAT)
</parent>
... (Several more parents)
</grandparent>
</greatgrandparent>
輸出:
<newprice>
$300$ <br/> $250 <br/> $200! <br/> Yes, that is right! <br/> You can own a ps3 for only $200
</newprice>
我似乎無法找到一個方法來做到這一點。
當前XSL:
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="greatgrandparents">
<xsl:apply-templates />
</xsl:template>
<xsl:template match = "grandparent">
<xsl:for-each select = "parent" >
<newprice>
<xsl:apply-templates>
</newprice>
</xsl:for-each>
</xsl:template>
<xsl:template match="description">
<xsl:element name="newprice">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="p">
<xsl:apply-templates/>
</xsl:template>
我會試試這個。我會讓你知道它是怎麼回事。我認爲我遇到了一個的問題,這是因爲一些奇怪的原因,在其中添加了其他字段。感謝您的迴應! –
Bilzac
2010-05-26 14:31:35
使用身份模板是'的關鍵''如果您需要一個完整的示例或足夠的話,請告訴我。 –
2010-05-26 14:38:18
呃。我無法讓它工作。它似乎是添加了所有描述的兄弟姐妹。 – Bilzac 2010-05-26 14:55:37