【问题标题】:How to parse CDATA or replace CDATA new line with <BR> in XSL?如何在 XSL 中解析 CDATA 或用 <BR> 替换 CDATA 新行?
【发布时间】:2014-07-24 11:07:30
【问题描述】:

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

<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 来使用“禁用输出转义”属性来检索它。

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

【问题讨论】:

    标签: xml xslt cdata


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2014-10-24
      • 2015-09-07
      • 1970-01-01
      • 1970-01-01
      • 2013-09-07
      • 2012-01-01
      • 2012-08-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多