gpt4 book ai didi

html - XSLT:解析嵌入在 XML 中的 HTML?

转载 作者:太空狗 更新时间:2023-10-29 14:48:29 25 4
gpt4 key购买 nike

在我的网站上,我的页面内容有 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>

但是,如果我只是使用以下方法获取内容:<xsl:value-of select="content" />所有 HTML 格式都被忽略/丢失。我猜它被误认为是 XML 子节点,而不是驻留在内容节点中的实际数据。

像此处描述的那样实现格式化的首选方法是什么?

提前致谢。

最佳答案

<xsl:value-of select="content" /> 

输出节点的。还有你的值(value)<content>节点实际上是:

This is an article. It's HUGE, and here's a link

What you probably need is to copy the entire node:

<xsl:copy-of select="content" /> 

这主要是一个猜测,因为我不知道你的系统是如何工作的。

关于html - XSLT:解析嵌入在 XML 中的 HTML?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1105176/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com