xml 评论

示例

XML中的注释如下所示:

<!-- This is a comment -->

它们可以出现在元素内容或顶级中:

<?xml version="1.0"?>
<!-- a comment at the top-level -->
<document>
  <!-- a comment inside the document -->
</document>

注释不能出现在标签或属性内:

<element <!-- comment with -- inside --> />

要么

<element attr="<!-- comment with -- inside -->"/>

格式不正确。

字符序列--不能出现在注释的中间。这不是格式正确的XML:

<!-- comment with -- inside -->

与其他语言(例如C ++)不同,XML注释是数据模型的一部分:它们被解析,转发并对使用中的应用程序可见。