如何设置HTML中显示的XML样式? [英] How to style XML displayed in HTML?

查看:266
本文介绍了如何设置HTML中显示的XML样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示从网站上的数据库中提取的XML。我希望能够显示它的显示方式(例如字符串值,属性,元素等不同的颜色)。

I'd like to display XML pulled from a database on a website. I'd like to be able to style how it is displayed (such as different colors for string value, attributes, elements,..).

您如何做到这一点?你可以使用CSS吗?谢谢!

How would you do this? Can you use CSS? Thanks!

编辑:我的意思是将XML作为XML编辑器显示,对于混淆抱歉!

I mean display the XML as XML editor would, sorry for the confusion!

推荐答案

(我正在解释您的问题是将XML内容显示为XML,但带有漂亮的语法突出显示,例如,用XML编辑器得到。)

(I'm interpreting your question to be about displaying the XML content as XML, but with pretty syntax highlighting, as you would get with an XML editor for example.)

我推荐 xmlverbatim 通过XSLT转换(服务器端或通过JavaScript)。您可以更改它的 indent-elements 参数,以控制是否希望它缩进XML。

I'd recommend xmlverbatim via an XSLT transform (either server-side or via JavaScript). You can change its indent-elements parameter to control whether you want it to indent the XML.

对于XSLT在客户端进行转换, xslt.js (可能与jQuery结合使用)应该有所帮助。

For the XSLT transform on the client side, xslt.js (possibly in conjunction with jQuery) should help.

这篇关于如何设置HTML中显示的XML样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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