Comments in XML are nearly identical to comments in HTML. Using comments allows you to understand code you wrote years before, or another developer to review.
Time Required: 5 minutes
- Comment tags are two parts, the part starting the comment and the part ending it. First, add the first part of the comment tag
- Write whatever comment you would like - just make sure you don't nest comments within other comments (see tips for more details).
- Close the comment tag
- Comments cannot come at the very top of your document. In XML, only the XML declaration can come first:
- Comments may not be nested one inside another. You must close your first comment before you open a second.
- Comments cannot occur within tags, e.g.
- Never use the two dashes (--) anywhere but at the beginning and end of your comments.
- Anything in comments is effectively invisible to the XML parser, so be very careful that what remains is still valid and well-formed.