How do I comment out a block of tags in XML?
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>
You can wrap the text with a non-existing processing-instruction, e.g.:
<detail>
<?ignore
<band height="20">
<staticText>
<reportElement x="180" y="0" width="200" height="20"/>
<text><![CDATA[Hello World!]]></text>
</staticText>
</band>
?>
</detail>
Nested processing instructions are not allowed and '?>' ends the processing instruction (see http://www.w3.org/TR/REC-xml/#sec-pi)
If you ask, because you got errors with the <!-- -->
syntax, it's most likely the CDATA section (and there the ]]>
part), that then lies in the middle of the comment. It should not make a difference, but ideal and real world can be quite a bit apart, sometimes (especially when it comes to XML processing).
Try to change the ]]>
, too:
<!--detail>
<band height="20">
<staticText>
<reportElement x="180" y="0" width="200" height="20"/>
<text><![CDATA[Hello World!]--><!--]></text>
</staticText>
</band>
</detail-->
Another thing, that comes to mind: If the content of your XML somewhere contains two hyphens, the comment immediately ends there:
<!-- <a> This is strange -- but true!</a> -->
--------------------------^ comment ends here
That's quite a common pitfall. It's inherited from the way SGML handles comments. (Read the XML spec on this topic)