微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我怎么能把& 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.

原文地址:https://www.jb51.cc/xml/293315.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。