如何在XML中转义&符号,以便它们在HTML中呈现为实体?(How do I escape ampersands in XML so they are rendered as entities in

编程入门 行业动态 更新时间:2024-10-25 22:25:15
如何在XML中转义&符号,以便它们在HTML中呈现为实体?(How do I escape ampersands in XML so they are rendered as entities in HTML?)

我有一些XML文本,我希望在HTML页面中呈现。 该文本包含一个&符号,我想在其实体表示中呈现: & 。

如何在源XML中避开这个&符号? 我试过& ,但这被解码为实际的&符号( & ),这在HTML中无效 。

所以我想逃避它,使它将被渲染为& 在使用XML输出的网页中。

I have some XML text that I wish to render in an HTML page. This text contains an ampersand, which I want to render in its entity representation: &.

How do I escape this ampersand in the source XML? I tried &, but this is decoded as the actual ampersand character (&), which is invalid in HTML.

So I want to escape it in such a way that it will be rendered as & in the web page that uses the XML output.

最满意答案

当您的XML包含& ,这将导致文本& 。

当您在HTML中使用它时,将被呈现为& 。

When your XML contains &, this will result in the text &.

When you use that in HTML, that will be rendered as &.

更多推荐

本文发布于:2023-07-29 14:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1316741.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实体   符号   如何在   rendered   XML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!