An XML document may contain comments. They may appear anywhere as long as they are not inside tags. They are even allowed in some locations inside the DTD (e.g., between entity declarations).

XML comments start with the string <!-- and end with the string -->.

Here are some examples of valid XML comments:

Example 7.6. XML Generic Comments
<!-- This is inside the comment -->

<!--This is another comment-->

<!-- This is how you
     write multiline comments -->

<p>A simple <!-- Comment inside an element's content --> paragraph.</p>

XML comments may contain any strings except --:

Example 7.7. Erroneous XML Comment
<!-- This comment--is wrong -->

7.5.1. To Do…

  1. Add some comments to example.xml, and check that the file still validates using xmllint.

  2. Add some invalid comments to example.xml, and see the error messages that xmllint gives when it encounters an invalid comment.

All FreeBSD documents are available for download at https://download.freebsd.org/ftp/doc/

Questions that are not answered by the documentation may be sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.