How to Add Comment in XML


xml

Solution

You can add a comment in the XML file by starting a line with <!-- and closing it with -->. An example:

<email>
  <to>Roman</to>
  <from>John</from>
  <heading>Meeting</heading>
  <!-- <body>Please call me ASAP</body> -->
</email>

You can’t comment only just opening or closing tag. The following example will be invalid:

<!--<email>-->
  <to>Roman</to>
  <from>John</from>
  <heading>Meeting</heading>
   <body>Please call me ASAP</body> 
</email>

This one as well:

<email>
  <to>Roman</to>
  <from>John</from>
  <heading>Meeting</heading>
   <body>Please call me ASAP</body> 
<!--</email>-->
comments powered by Disqus