XSLT:解析XML中嵌入的HTML? [英] XSLT: Parsing HTML embedded in XML?

查看:92
本文介绍了XSLT:解析XML中嵌入的HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

On my web site I have XMLs with my page contents (automatically generated from my DB) - which are displayed using XSLT. The problem is this: I'd like to have some formatting within some of the XML tags. For instance, if I have an XML containing an article in a format like this:

<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子节点,而不是实际的数据驻留在内容节点。

However, if I simply get the contents using this: <xsl:value-of select="content" /> all the HTML formatting is ignored/lost. I guess it's mistaken for XML child nodes, and not actual data residing in the content node.

实现格式化的首选方式如此处所述?

What's the preferred way of achieving formatting like what described here?

在此先感谢。

推荐答案

我认为您的问题是这样的:

I think your problem is this:

 <xsl:output method="xml" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
          media-type="application/html+xml" encoding="utf-8" omit-xml-declaration="yes" indent="no"/>

请确保您的输出是html类型的,

make sure your output is of type html,

application/html

这篇关于XSLT:解析XML中嵌入的HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆