相关疑难解决方法(0)

在XSL中从CDATA标记内呈现HTML标记

我的XML代码中有一个CDATA标记,其中包含一些超链接.

<smartText><![CDATA[
Among individual stocks, the top percentage gainers in the S.&P. 500 are
<a href ='http://investing.domain.com/research/stocks/snapshot
/snapshot.asp?ric=LNC'>Lincoln National Corp</a> and 
<a href ='http://investing.domain.com/research/stocks/snapshot
/snapshot.asp?ric=PLD'>ProLogis</a>.]]>
</smartText>
Run Code Online (Sandbox Code Playgroud)

我正在尝试将其转换为HTML页面,如下所示......

<p class="smartText">
    <xsl:copy-of select="marketSummaryModuleData/smartText"/>                                    
</p>    
Run Code Online (Sandbox Code Playgroud)

不幸的是,页面上的输出显示为纯文本,而不是html.

Among individual stocks, the top percentage gainers in the S.&P. 500 are <a href ='http://investing.businessweek.com/research/stocks/snapshot/snapshot.asp?ric=PLD'>ProLogis</a> and <a href ='http://investing.businessweek.com/research/stocks/snapshot/snapshot.asp?ric=LNC'>Lincoln National Corp</a>.
Run Code Online (Sandbox Code Playgroud)

CDATA部分是从经典的ASP页面创建的,因此实际的XML输出不包含CDATA部分.这可能是问题的一部分吗?我似乎无法获取要在页面上呈现的信息.我尝试了Google搜索提供的多种解决方案,例如disable-escape-tags,xsl:copy-of,xsl:value-of等等.

谢谢

xml xslt cdata

11
推荐指数
2
解决办法
2万
查看次数

XSLT:解析嵌入XML的HTML?

在我的网站上,我有我的页面内容的XML(从我的数据库自动生成) - 使用XSLT显示.问题是这样的:我想在一些XML标签中有一些格式.例如,如果我有一个包含如下格式的文章的XML:

<article>
  <header>Cool article</header>
  <author>Me!</author>
  <content>
    This is an article. It's <b>HUGE</b>, and here's a <a href="http://Www.foo.com">link</a>.
  </content>
</article>
Run Code Online (Sandbox Code Playgroud)

但是,如果我只使用此获取内容:<xsl:value-of select="content" />忽略/丢失所有HTML格式.我猜这是错误的XML子节点,而不是驻留在内容节点中的实际数据.

如此处所描述的那样,实现格式化的首选方式是什么?

提前致谢.

html xslt

6
推荐指数
2
解决办法
8993
查看次数

标签 统计

xslt ×2

cdata ×1

html ×1

xml ×1