This chapter explains how comments work in XML documents. XML comments are similar to HTML comments. The comments are added as notes or lines for understanding the purpose of an XML code.
Comments can be used to include related links, information, and terms. They are visible only in the source code; not in the XML code. Comments may appear anywhere in XML code.
XML comment has the following syntax −
<!--Your comment-->
A comment starts with <!-- and ends with -->. You can add textual notes as comments between the characters. You must not nest one comment inside the other.
Following example demonstrates the use of comments in XML document −
<?xml version = "1.0" encoding = "UTF-8" ?> <!--Students grades are uploaded by months--> <class_list> <student> <name>Tanmay</name> <grade>A</grade> </student> </class_list>
Any text between <!-- and --> characters is considered as a comment.
Following rules should be followed for XML comments −