在 XML 中使用大于号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/330725/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 12:13:45  来源:igfitidea点击:

Use of Greater Than Symbol in XML

xmlxsd

提问by praveenjayapal

I had created the xml document with xml version="1.0".

我用 xml version="1.0" 创建了 xml 文档。

In that document I need to use the greater than symbol >and less than symbol <.

在该文档中,我需要使用大于符号>和小于符号<

How should I include those symbols? It's not working.

我应该如何包含这些符号?它不起作用。

&gt;and &lt;are not working for me.

&gt;并且&lt;不对我来说有效。

Is there any special encoder for this?

是否有任何特殊的编码器?

回答by Greg

You need the Character Entity References

您需要字符实体引用

< = &lt;

< = &lt;

> = &gt;

> = &gt;

回答by Patrick Desjardins

You can try to use CDATAto put all your symbols that don't work.

您可以尝试使用CDATA来放置所有不起作用的符号。

An example of something that will work in XML:

将在 XML 中工作的示例:

<![CDATA[
function matchwo(a,b) {
    if (a < b && a < 0) {
        return 1;
   } else {
       return 0;
   }
}
]]>

And of course you can use &lt;and &gt;.

当然你可以使用&lt;and &gt;

回答by tonys

Use &gt;and &lt;for 'greater-than' and 'less-than' respectively

使用&gt;&lt;分别“低于”大于'和

回答by annakata

CDATAis a better general solution.

CDATA是更好的通用解决方案。