DOM - Comment Object


In this chapter, we will study about the Comment object. Comments are added as a notes or the lines for understanding the purpose of an XML code. Comments can be used to include related links, information and terms. These may appear anywhere in the XML code.

The comment interface inherits the CharacterData interface representing the content of the comment.


XML comment has the following syntax −

<!-------Your comment----->

A comment starts with <!-- and ends with -->. You can add textual notes as comments between the characters. You must not nest one comment inside the other.

There are no methods and attributes defined for the Comment object. It inherits those of its parent, CharacterData, and indirectly those of Node.