XML technologies / XML / XML in a Nutshell / XML basics / Comments

(Excerpt from "XML in a Nutshell" by Elliotte Rusty Harold & W. Scott Means)

XML documents can contain comments, allowing co-authors to leave notes for themselves and one another explaining what they have done and what remains to be done. XML comments are syntactically similar to HTML comments. As in HTML, they begin with <!-- and end at the first occurrence of -->. For example:

<!-- Ich muss diese Links irgendwann noch einmal testen und aktualisieren. -->

The double hyphen -- should not appear inside a comment; it is reserved for the closing sequence -->. A triple hyphen as part of the closing sequence ---> is strictly forbidden!

Comments may occur anywhere in a document’s character data, including before or after the root element. Since comments are not elements, they do not violate the tree structure or the rule that XML has only one root element. However, comments may not occur inside a tag or another comment.

Applications reading and processing XML documents need not pass through information from comments; they may remove it. Do not write documents or applications that depend on comment contents being available. Comments serve only to make source code clearer to human readers, not to communicate with programs. For that purpose, use a processing instruction.

  

 

 

 

back to top