January 2003
Beginner to intermediate
1200 pages
23h 42m
English
XML comments are very much like HTML comments. You can use comments to include explanatory notes in your document that are ignored by XML parsers; comments may appear anywhere in a document outside other markup. As in HTML, you start a comment with <!-- and end it with -->. Here's an example:
<?xml version="1.0" encoding="UTF-8"?>
<DOCUMENT>
<!--Start the document off with a greeting.-->
<GREETING>
<!--Here's the greeting's text.-->
Hello from XML!
</GREETING>
</DOCUMENT>
You should follow a few rules when adding comments to an XML document:
Comments must not come before an XML declaration. For example, this is incorrect:
<!--Here's my document.--> <?xml version="1.0" encoding="UTF-8"?> <DOCUMENT> <GREETING> Hello from XML! </GREETING> ...