如何注释XML中的标记块?

即,我如何在下面的代码中注释<staticText>及其内部的所有内容?

  <detail>
    <band height="20">
      <staticText>
        <reportElement x="180" y="0" width="200" height="20"/>
        <text><![CDATA[Hello World!]]></text>
      </staticText>
    </band>
  </detail>

我可以用<!--staticText-->但这仅适用于单个标记(如我所知),如Java和C中的//。


当前回答

XML语法:<!--您的评论-->

eg.

<?xml版本=“1.0”编码=“UTF-8”?><!--以下是您的评论:)--><class_list><学生><name></name><grade>A</grade></学生></class_list>

XML注释规则

Comments cannot appear before XML declaration.
Comments may appear anywhere in a document.
Comments must not appear within attribute values.
Comments cannot be nested inside the other comments.

其他回答

实际上,您可以使用<!--…-->具有多行或标记的格式:

<!--
  ...
  ...
  ...
-->

如果您使用的是EclipseIDE,可以通过突出显示XML文件中的行并按Ctrl+Shift+c来注释这些行。

XML语法:<!--您的评论-->

eg.

<?xml版本=“1.0”编码=“UTF-8”?><!--以下是您的评论:)--><class_list><学生><name></name><grade>A</grade></学生></class_list>

XML注释规则

Comments cannot appear before XML declaration.
Comments may appear anywhere in a document.
Comments must not appear within attribute values.
Comments cannot be nested inside the other comments.

您可以使用以下命令轻松注释数据:

<!-- 
 <data>
        <data-field1></data-field1>
        <data-field2></data-field2>
        <data-field3></data-field3>
 </data>
-->

xml中注释的方法。

在Notepad++中,您可以选择几行并使用CTRL+Q,这将自动为所选行生成块注释。