O'Reilly logo

Real World XML by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required