“Content is not allowed in prolog” error yet nothing before XML declaration

本小妞迷上赌 提交于 2019-12-02 01:58:35

Elaborating on what @MartinHonnen has already helpfully commented...

The error,

Content is not allowed in prolog.

arises because the XML prolog, which is everything before the root element in an XML document, has textual content that is not allowed. The error does not necessarily have to have occurred before the XML declaration.

Specifically, the prolog in XML is defined in the context of an XML document:

[1] document      ::= prolog element Misc*

Note that prolog precedes element, the single root element of the XML document.

Most answers focus on the problem where there is text (visible or invisible) at the beginning of the prolog, before the XML declaration, but note that non-whitespace text cannot appear anywhere within or after the prolog either:

[22] prolog      ::= XMLDecl? Misc* (doctypedecl Misc*)?
[23] XMLDecl     ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
[24] VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"')
[25] Eq          ::= S? '=' S?
[26] VersionNum  ::= '1.' [0-9]+
[27] Misc        ::= Comment | PI | S

In your case, you have Test material... text content appearing between the XML declaration (XMLDecl) and the root element (element). A comment, processing instruction, or whitespace can appear there, but not text.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!