XML guides

Remove an XML comment without changing a CDATA example

·

The characters that open a comment have a special meaning in markup. The same spelling can be ordinary data inside a CDATA section.

XML Comment Remover

Keep a literal example

Enter <r><!-- draft --><code><![CDATA[<!-- keep -->]]></code></r>. The download contains the code element and the complete CDATA section. The draft comment is gone.

W3C Extensible Markup Language 1.0

Check text on both sides

Compare <r>one<!-- editor -->two</r> with <r>one <!-- editor -->two</r>. Removing the comment gives onetwo in the first root and one two in the second. The existing space determines the output.

W3C Extensible Markup Language 1.0

Strip an editorial note while keeping a printed example

A documentation build may contain both internal comments and literal XML for readers. Paste this release note into the remover. Inspect the result as text before feeding it to the publishing system.

Release note with an editorial comment
<note>Ship <!-- awaiting approval -->today.</note>
  • The result is <note>Ship today.</note>. Put the space before the opening comment inside the comment instead and the words will run together. If the private note also appears in a text node or attribute, deleting XML comments alone will leave that copy in place.

Common questions

Will attributes be reordered?

The remover edits comment spans in the original source. Attribute order, quotation style and spacing outside those spans are preserved.

What if the comment itself is malformed?

The parser reports the invalid XML. Correct the comment or other syntax in the source before retrying.

Sources

Put it into practice.

Related guides