XML 属性中哪些字符无效(除非已编码)? [英] Which characters are Invalid (unless encoded) in an XML attribute?
本文介绍了XML 属性中哪些字符无效(除非已编码)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不敢相信我无法轻松访问此信息,因此:
I can't believe I can't find this information easily accessible, so:
1) 哪些字符不能在没有实体编码的情况下合并到 XML 属性中?
1) Which characters cannot be incorporated in an XML attribute without entity-encoding them?
显然,您需要对引号进行编码.<
和 >
怎么样?还有什么?
Obviously, you need to encode quotes. What about <
and >
? What else?
2) 官方名单具体在哪里?
2) Where exactly is the official list?
推荐答案
这里是属性值中允许的内容.
'"' ([^<&"] | Reference)* '"' | "'" ([^<&'] | Reference)* "'"
所以,你不能:
- 打开/关闭属性值的相同字符(任一
'
或"
) - 裸露的&符号(
&
必须是&
) - 一个左尖括号(
<
必须是<
)
- the same character that opens/closes the attribute value (either
'
or"
) - a naked ampersand (
&
must be&
) - a left angle bracket (
<
must be<
)
您也不应该使用任何完全不合法的字符XML 文档中的任何位置(例如表单提要等).
You should also not being using any characters that are outright not legal anywhere in an XML document (such as form feeds, etc).
这篇关于XML 属性中哪些字符无效(除非已编码)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文