This article mainly introduces the detailed method of writing code comments in XML. The article summarizes some points to pay attention to when using comments, such as XML does not support nested comments, etc. Friends who need it can refer to it
XML comments are similar to HTML comments. Comments are used to add explanation or understand a line of XML code.
Comments can be used to include relevant links, information and terms. They are only visible in the source code, not the XML code. Comments can appear anywhere in the XML code.
Grammar
Explanation starts with , for example .
Comments can appear in the preamble of a document, including a document type definition (DTD); after the document; or in the text content. Comments cannot appear in attribute values. Cannot appear in markup.
The parser considers the comment to have ended when it encounters >; then continues processing the document as normal XML. Therefore, the string > cannot appear in comments. Apart from this restriction, any legal XML character can appear in a comment, much like a CDATA section. This allows the XML comments to be removed from the output stream seen by the parser without deleting the content of the document.
The following comments can be used to temporarily remove markers.
Example
The following is a demonstration example of using comments in an XML document:
<?xml version="1.0" encoding="UTF-8" ?> <!---Students grades are uploaded by months----> <class_list> <student> <name>Tanmay</name> <grade>A</grade> </student> </class_list>
Note# Text between
## characters is considered a comment. ## XML comment rules The following are the rules that XML comments need to follow:- Comments cannot appear before an XML declaration.
- Comments can appear anywhere in the document.
- Comments cannot appear in attribute values.
- Comments cannot be nested within other comments.
The above is the detailed content of Detailed explanation of how to write code comments in XML. For more information, please follow other related articles on the PHP Chinese website!