In this tutorial, You learn below things writing XML comments.
XML Comments
the developer writes Comments
to describe the line of text or tag in XML.
processor or parser ignores comments during XML parse.
Comments start with (less than, exclamation symbol and two dashes) <!--
and end with (two dashes followed by greater than symbol)-->
Comments can be single or multi-line comments.
Multi-line comments Syntax:
<!-- multiple lines comments
text -->
Comment text is placed in multiple lines wrapped in comment syntax. Comment text can have string text or tags.
Here is XML multiple line comments example
<users>
<user id="1">
<!--
Hello
This is single user comments
<name>john<name>
<salary>5000</salary>
-->
</user>
</user>
Single line comments:
Comments text is placed in a single-line Syntax:
<!-- Comments text -->
Here is XML single line comments example
<users>
<user id="1">
<!-- Hello This is single user comments -->
</user>
</user>
Comments writes using followings things.
- Can write in the content
- Not allowed in XML attributes
- Allowed inside a tag
- nested comments are not allowed
XML Comments example:
Following is an example
<!--
XML document for a list of users
Each user has an information id attribute, name, and salary
-->
<users>
<user id="1">
<name>john<name><!-- name of employee -->
<salary>5000</salary> <!-- salary of employee -->
</user>
</user>
How do I comment out a block of tags in XML?
It is very easy to comment Block of tags with multi-line syntax.
Multi-line comments starts with <!--
followed by comments, end with -->
<emps>
<emp id="1">
<!--
Hi
Multi-line comments in HTML tags
<name>eric<name>
<salary>4000</salary>
-->
</emp>
</emps>