Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>According to the <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#sec-comments" rel="noreferrer">XML specification</a>, a well-formed XML document is:</p> <blockquote> <p><code>document ::= prolog element Misc*</code></p> </blockquote> <p>where <code>prolog</code> is</p> <blockquote> <p><code>prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?</code></p> </blockquote> <p>and</p> <blockquote> <p><code>XMLDecl ::= '&lt;?xml' VersionInfo EncodingDecl? SDDecl? S? '?&gt;'</code></p> </blockquote> <p>which means that, if you want to have comments at the top, you cannot have an XML type declaration.</p> <p>The specification agrees with Wikipedia on comments:</p> <blockquote> <p>2.5 Comments</p> <p>[Definition: Comments may appear anywhere in a document outside other markup; in addition, they may appear within the document type declaration at places allowed by the grammar. They are not part of the document's character data; an XML processor MAY, but need not, make it possible for an application to retrieve the text of comments. For compatibility, the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity references MUST NOT be recognized within comments.</p> </blockquote> <p>All of this together means that you can put comments <strong>anywhere that's not inside other markup</strong>, except that you <strong>cannot have an XML declaration if you lead with a comment</strong>.</p> <p>However, while in theory theory agrees with practice, in practice it doesn't, so I'd be curious to see how your experiment works out.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload