XML – Comments

XML Comment is used to mention the brief description or the small note about the XML code. Even though the elements are self-descriptive, we may require the comment at some places. There is no difference between HTML comments and XML comments syntax. Both will have same syntax.

Syntax:

<! ---- Comments Here ------>

Example:

<? xml version="1.0" encoding="UTF-8"?> 
<! ---- List of customers category wise ------> 
<customer_list> 
	<customer category="Gold"> 
		<name> Sanjay</name> 
		<location> Mumbai</location> 
	</customer> 
	<customer category="Silver"> 
		<name> Micheal</name> 
		<location> Washington</location> 
	</customer> 
</customer_list> 

Also, we should be careful about the placement of comments. Comments can be placed before the XML declaration or anywhere in the XML document but nor inside element tags or attributes.