Cheap VPS & Xen Server


Residential Proxy Network - Hourly & Monthly Packages

XML Comments


XML comments are just like HTML comments. We know that the comments are used to make codes more understandable other developers.

XML Comments add notes or lines for understanding the purpose of an XML code. Although XML is known as self-describing data but sometimes XML comments are necessary.

Syntax

An XML comment should be written as:

  1. <!– Write your comment–>

You cannot nest one XML comment inside the another.

XML Comments Example

Let’s take an example to show the use of comment in an XML example:

  1. <?xml version=“1.0” encoding=“UTF-8” ?>
  2. <!–Students marks are uploaded by months–>
  3. <students>
  4.    <student>
  5.       <name>Ratan</name>
  6.       <marks>70</marks>
  7.    </student>
  8.    <student>
  9.       <name>Aryan</name>
  10.       <marks>60</marks>
  11.    </student>
  12.  </students>

Test it Now


Rules for adding XML comments

  • Don’t use a comment before an XML declaration.
  • You can use a comment anywhere in XML document except within attribute value.
  • Don’t nest a comment inside the other comment.

Comments

comments