Comments
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> ...
Get Inside XML now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.