Comments

XML comments contain human-readable information and are formed the same way SGML (and thus HTML) comments are formed.

Productions

[15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'

Examples

<!--This is a very simple document.-->

<!--
   This comment is on
   several lines.
-->

Description

Comments begin with <!-- and end with —>. They can contain characters that are illegal in text (character data) such as & and <; however, they can’t contain the character sequence -- or --->, and they cannot be nested. XML processors generally ignore comments but may keep track of them. You can place comments anywhere in an XML document except inside other markup, such as within tag brackets. You can also place comments inside document type declarations, where allowed. Entity references and parameter entity references (such as &lt; or %data;) are allowed but not recognized or expanded inside comments.

See also

§2.5

Get XML Pocket Reference, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.