XML Comment

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

xml comment

A comment is used to leave a note or to temporarily edit out a portion of XML code. Although XML is supposed to be self-describing data, you may still come across some instances where an XML comment might be necessary.

xml comment syntax

XML comments have the exact same syntax as HTML comments. Below is an example of a notation comment that should be used when you need to leave a note to yourself or to someone who may be viewing your XML.

XML Code:

<?xml version="1.0" encoding="ISO-8859-15"?>
<!-- Students grades are updated bi-monthly -->
<class_list>
	<student>
		<name>Robert</name>
		<grade>A+</grade>
	</student>
	<student>
		<name>Lenard</name>
		<grade>A-</grade>
	</student>
</class_list>

xml commenting out xml

For many different reasons, sometimes you might want to temporarily remove some XML code from your XML document. XML Comments let you do this easily, as this example below shows.

XML Code:

<?xml version="1.0" encoding="ISO-8859-15"?>

<class_list>
	<student>
		<name>Robert</name>
		<grade>A+</grade>
	</student>
<!--
	<student>
		<name>Lenard</name>
		<grade>A-</grade>
	</student> 
-->
</class_list>