开发者

How to style XML displayed in HTML?

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

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

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


Have a look at XSL/XSLT.


(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.)

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.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜