Xml 简明教程
XML - Comments
本章介绍了 XML 文档中注释的工作方式。 XML comments 类似于 HTML 注释。注释以笔记或行的形式添加,以便理解 XML 代码的目的。
This chapter explains how comments work in XML documents. XML comments are similar to HTML comments. The comments are added as notes or lines for understanding the purpose of an XML code.
注释可用于包含相关链接、信息和术语。它们只在源代码中可见;不在 XML 代码中。注释可以出现在 XML 代码中的任何位置。
Comments can be used to include related links, information, and terms. They are visible only in the source code; not in the XML code. Comments may appear anywhere in XML code.
Syntax
XML 注释具有以下语法 -
XML comment has the following syntax −
<!--Your comment-->
注释以 <!-- 开始,以 -→ 结束。你可以在字符之间以注释的形式添加文本笔记。你不得将一个注释嵌套在另一个注释中。
A comment starts with <!-- and ends with -→. You can add textual notes as comments between the characters. You must not nest one comment inside the other.
Example
以下示例演示了在 XML 文档中使用注释 −
Following example demonstrates the use of comments in 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>
<!-- 和 -→ 字符之间的任何文本都被视为注释。
Any text between <!-- and -→ characters is considered as a comment.