将XML声明之前的注释放在XML文件中可以吗?
<!-- Is this bad to do? --> <?xml version="1.0" encoding="utf-8"?> <someElement />
不,不行
Because each XML entity not
@H_404_20@
accompanied by external encoding
information and not in UTF-8 or UTF-16
encoding must begin with an XML
encoding declaration,in which the
first characters must be ‘< ?xml’,any
conforming processor can detect,after
two to four octets of input,which of
the following cases apply.啊,但是,F节是非规范的,你说。
那么,section 2.1给出了一个格式良好的XML文档的生产,因此:
[1] document ::= prolog element Misc*…在section 2.8我们得到了“prolog”的生产:
[22] prolog ::= XMLDecl? Misc* (doctypedecl Misc*)? [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'所以,你可以省略< ?xml声明,但你不能用任何东西前缀。 (顺便提及,“杂项”是评论的类别)。