- 59 -
XML parsers ignore everything within comment tags, so you can pretty much use any
characters in a comment; however, make sure you don’t include the -- string inside the
comment itself. For example:
like -->
would be considered not well formed, and any XML parser worth its salt would reject it.
Comments can also be arbitrarily long; that is, there is no limit to their size. They can
span several lines:
absolutely no meaning whatsoever other
than to take up a lot of space -->
You can also use comments to
comment out
sections that you don’t want the parser to
read, for example:
element -->
this element and its contents are being ignored by
the
parser
-->
If you’re in the habit of commenting out code while writing C++ or Java applications, you
will almost certainly appreciate how useful comments can be for debugging purposes—
especially if you are using a parser that has terse error reporting (for example, “Error in
document. Please correct and then retry.”). A few words of advice: Please don’t ever use
a parser that reports errors as tersely as that.