如何解析CDATA或用XSL替换CDATA新行?

时间:2014-07-24 11:07:31

标签: xml xslt cdata

我有一个带有CDATA内容的外部xml Feed(纯文本格式)

<RSS_Description><![CDATA[
This is the documentation for Book 1

This is published by Mr Smith

This is 3rd edition of publishing
]]></RSS_Description>

现在我有了我的xsl来检索这个&#34; disable-output-escaping&#34;属性。

RSS Description :<br><xsl:value-of select="RSS_Description" disable-output-escaping="yes"/>

它在浏览器视图中显示了1行内容。

它看起来像这样。

RSS Description : This is the documentation for Book 1This is published by Mr SmithThis is 3rd edition of publishing

我的问题:有没有办法让显示与检索到的XML节点相同?随着换行。

RSS Description : 
This is the documentation for Book 1

This is published by Mr Smith

This is 3rd edition of publishing

1 个答案:

答案 0 :(得分:2)

如果转换为HTML,则使用pre元素,例如

<pre style="white-space: pre;">
  <xsl:value-of select="RSS_Description"/>
</pre>