start page | rating of books | rating of authors | reviews | copyrights

Book HomeXML in a NutshellSearch this book

2.7. Comments

XML documents can be commented so that coauthors can leave notes for each other and themselves, documenting why they've done what they've done or items that remain to be done. XML comments are syntactically similar to HTML comments. Just as in HTML, they begin with <!-- and end with the first occurrence of -->. For example:

<!-- I need to verify and update these links when I get a chance. -->

The double hyphen -- should not appear anywhere inside the comment until the closing -->. In particular, a three hyphen close like ---> is specifically forbidden.

Comments may appear anywhere in the character data of a document. They may also appear before or after the root element. (Comments are not elements, so this does not violate the tree structure or the one-root element rules for XML.) However, comments may not appear inside a tag or inside another comment.

Applications that read and process XML documents may or may not pass along information included in comments. They are certainly free to drop them out if they choose. Do not write documents or applications that depend on the contents of comments being available. Comments are strictly for making the raw source code of an XML document more legible to human readers. They are not intended for computer programs. For this purpose you should use a processing instruction instead.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.