XML comment tags are completely ignored to display by the browsers. It's used to insert comments into the source code. This lesson describes how to write comments in XML.



Comment can be used anywhere to add information about XML tags or data, which will help developers understand the existing code in the future easily.

The syntax for writing comments in XML is similar to the syntax of writing comments in HTML.

Syntax:

<!--This is a comment area, write your comment-->

Example:

<?xml version="1.0" encoding="UTF-8" ?>
<!-- Employee Information-->
<address>
  <name>Alex</name>
  <company>w3schools</company>
  <phone>(091) 123-4567</phone>
</address>

XML Comments Rules

  • Comment cannot be used before an XML declaration.
  • Comment cannot be used within the attribute value.
  • There is no meaning to used comments inside a comment.


Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram