XML code snippets to browser friendly HTML

和自甴很熟 提交于 2019-12-23 01:52:10

问题


Is there an online tool to convert XML code snippets to browser friendly html?

I just want to post my XML code to a forum for viewing purposes and nothing else but the TAGs mess up the HTML.


回答1:


To display strings containing reserved characters in HTML (<, > and &), you need to convert those characters into HTML entities.

For example, the HTML entity for < is &lt;.

There are tools in most languages for converting reserved HTML characters into entities. For example, in PHP, you can use the htmlentities() function.

You'll need to tell us which language(s) you're working with before I can give you any more language-specific advice though.

But in general, it's just a case of replacing all instances of those three characters with their entity alternatives, so a fairly simple set of string replacements is all you really need.



来源:https://stackoverflow.com/questions/5962637/xml-code-snippets-to-browser-friendly-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!