Content that is not intended for the XML parser, such as notes about document structure or editing, can be included in a comment. Comments begin with a
<!-- and end with a --
>, for example,
<!--catalog last updated 2000-11-01-->.
Comments can appear in the document prolog, including the document type definition (DTD); after the document; or in the textual content. Comments cannot appear within attribute values. They cannot appear inside of tags.
The parser considers the comment finished when it encounters a
>; it then resumes processing the document as normal XML. For this reason, the string
> cannot appear inside of a comment. Apart from that restriction, any legal XML characters can appear in a comment, much like a CDATA section. This makes them very useful for removing XML comment from the stream seen by the parser without removing the content from the document.
The following comment can be used to strip out markup temporarily.
<!--- <test pattern="SECAM" /><test pattern="NTSC" /> -->
|In HTML, you can use comments to hide scripts and style sheets. To use this technique in XML, you might have to retrieve the comment, extract its contents, check for markup characters, and then reparse it. In this case, CDATA sections are a better option.|