Search code examples
xmlcomments

How do I comment out a block of tags in XML?


How do I comment out a block of tags in XML?

I.e. How can I comment out <staticText> and everything inside it, in the code below?

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

I could use <!-- staticText--> but that's just for single tags (as what I know), like // in Java and C. I would like something more like how /** comment **/ can be used in Java and C, so I can comment out longer blocks of XML code.


Solution

  • You can use that style of comment across multiple lines (which exists also in HTML)

    <detail>
        <band height="20">
        <!--
          Hello,
             I am a multi-line XML comment
             <staticText>
                <reportElement x="180" y="0" width="200" height="20"/>
                <text><![CDATA[Hello World!]]></text>
              </staticText>
          -->
         </band>
    </detail>