This article mainly introduces the code annotation writing method in XML, and summarizes some notes for using annotations, such as XML does not support nested annotations, for more information about how to write code annotations in XML, see the next article. The article summarizes some notes for using annotations, for example, XML does not support nested annotations, for more information, see
XML and HTML annotations are similar. Annotations are used to add instructions or understand a line of XML code.
Annotations can be used to contain related links, information, and terms. They are only visible in the source code, rather than in the XML code. Annotations can appear anywhere in the XML code.
Syntax
Shiji End, for example .
Annotations can appear in the document's preface, including document type definitions (DTD); after a document; or in text content. Annotations cannot appear in attribute values. It cannot appear in the tag.
When the analyzer encounters>, it considers that the comment has ended; then it continues to process the document as a normal XML. Therefore, strings> cannot appear in comments. In addition to this restriction, any valid XML characters can appear in comments, which is very similar to the CDATA section. In this way, you can delete XML comments from the output stream seen by the analyzer without deleting the document content.
The following annotations can be used to temporarily remove tags.
Example
The following is an example of using annotations in an XML document:
Tanmay
A
Note:
The text between characters is considered as comments. # Below are the rules for XML annotations:
-Annotations cannot appear before the XML declaration.
-Annotations can appear anywhere in the document.
-Annotations cannot appear in attribute values.
-Annotations cannot be nested in other annotations.
In HTML, you can use annotations to hide scripts and style sheets. To use this method in XML, you may have to retrieve comments, extract comments, check whether there are markup characters, and re-analyze them. In this example, the CDATA section is a better choice.
The above is the detailed description of the code comment writing method in XML. For more information, see other related articles in the first PHP community!