加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

如何在XML文档中包含&符号(&)?

发布时间:2020-12-16 08:02:29 所属栏目:百科 来源:网络整理
导读:我怎么能把 XML标记的属性中的符号,同时保持XML有效? ?xml version="1.0" ? a text="bc"/ 当我使用W3School’s validator,我得到错误: EntityRef: expecting ‘ ; ‘ 使用字符参考来表示它: amp; amp; amp; 见specification: The ampersand character
我怎么能把& XML标记的属性中的符号,同时保持XML有效?
<?xml version="1.0" ?> 
<a text="b&c"/>

当我使用W3School’s validator,我得到错误:

EntityRef: expecting ‘;

使用字符参考来表示它:& amp; amp; amp;

见specification:

The ampersand character (&) and the left angle bracket (<) MUST NOT appear in their literal form,except when used as markup delimiters,or within a comment,a processing instruction,or a CDATA section.

If they are needed elsewhere,they MUST be escaped using either numeric character references or the strings ”
&amp;
” and ”
&lt;
” respectively. The right angle bracket (>) may be represented using the string ”
&gt;
“,and MUST,for compatibility,be escaped using either ”
&gt;
” or a character reference when it appears in the string ”
]]> ” in content,when that string is not marking the end of a CDATA section.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读