Not only will you sometimes want to include tags in your XML document that
you want the XML processor will ignore (display as character data),
but sometimes you will want to put character data in your document that you
want the XML processor to ignore (not display at all). This type of text is
called COMMENT text.
You will be familiar with comments from HTML. In HTML, you specified comments using the
<!-- and --> syntax. Well, I have some good news. In XML, comments are done
in just the same way! So the following would be a valid XML comment:
<!-- Begin the Names -->
<NAME>Jim Nelson</NAME>
<NAME>Jim Sanger</NAME>
<NAME>Les Moore</NAME>
<!-- End the names -->
When using comments in your XML documents, however, you should keep in
mind a couple of rules.
First, you should never have "-" or "--" within the text of your comment
as it might be confusing to the XML processor.
Second, never place a comment within a tag. Thus, the following code
would be poorly-formed XML
<NAME <!--The name --> >Peter Williams</NAME>
Likewise, never place a comment inside of an entity declaration and never place a comment before
the XML declaration that must always be the first line in any XML document.