Compact XML while preserving text around inline elements
Admin ·
Some indentation is document data. Compare default output with the optional whitespace pass before choosing a representation for another application.
Shorten an empty element
Enter <items><item id = "007" ></item></items>. Compress with both options clear. The empty item becomes <item id="007"/> and the reported output is smaller.
Protect a preformatted branch
Try <p>Tea <b>set</b> today</p>. The spaces around b remain even when indentation removal is enabled. In a parent whose children are all elements, indentation-only text can be removed. Set xml:space="preserve" on that parent to keep those text nodes.
Keep a space that belongs to a sentence
A document can mix text and inline elements. Compress this letter with comment removal selected and check the characters on either side of the name. A text comparison is more informative than a screenshot because many viewers collapse spaces.
<p>Hello <b>Jo</b>!<!-- internal --></p>- The visible sentence should still read Hello Jo! with a space after Hello. If the receiving system needs the internal comment for its own processing, repeat the export from the original with comment removal disabled.
Common questions
Does the output use gzip?
The download is an ordinary XML text file. Its size is measured before transport or archive compression.
Will an XML signature survive these edits?
XML signatures depend on the signed nodes and canonicalization algorithm. Verify the signature in the receiving application before using a transformed signed document.