Home >>XML Tutorial >XML Comments

XML Comments

XML Comments

Comments in XML are much like comments in HTML. We are mindful that the comments are intended to render certain developers' software more understandable.

XML Comments add notes or lines to comprehend the purpose of XML code. Though XML is known as data self-description, XML comments are sometimes required.

Syntax

An XML comment should be written as:

XML Comments Example

Let's take an illustration of an XML document to show how comment is used:


<?xml version="1.0" encoding="UTF-8" ?>  
<!--Students marks -->  
<students>  
<student>  
<name>AB</name>  
<marks>55</marks>  
</student>  
<student>  
<name>CD</name>  
<marks>80</marks>  
</student>  
</students>   

Rules for adding XML comments

  • Do not use a comment before declaring an XML.
  • A comment can be used anywhere in the XML document except within the value of the attribute.
  • Don't nest the other comment inside.

No Sidebar ads