XMLPRETTY(1)
π NAME π
xmlpretty is literally an XML pretty printer β thatβs the whole name vibe. β¨
πΈ SYNOPSIS πΈ
xmlpretty [--options] [filename]
π¦ DESCRIPTION π¦
xmlpretty is the commandline interface to XML::Handler::YAWriter, acting as a tool to add and remove pretty printing to XML files. It has several methods to add human readability. π
If you want to add readability without adding so-called ignorable whitespace, use it in the following way:
$ xmlpretty --AddHiddenNewline \
--AddHiddenAttrTab \
--CatchEmptyElement \
uglyfile.xml > prettyfile.xml
If you do not want to process the file further, but only want it human readable, add visible whitespace to the file as follows:
$ xmlpretty --PrettyWhiteNewline \
--PrettyWhiteIndent \
--CatchEmptyElement \
uglyfile.xml > prettyfile.xml
You may use YAWriter to clean whitespace from XML documents. This may work in 99% of the cases where you want to get rid of ignorable whitespace caused by the various forms of pretty printing. π§
$ xmlpretty --NoWhiteSpace \
--NoComments \
--AddHiddenNewline \
--AddHiddenAttrTab \
--CatchEmptyElement \
prettyfile.xml > cleanfile.xml
π Options π
Options are given in a gnu like --option idiom. Slay, letβs go through them. π
--AddHiddenNewlineβ boolean: adds a hidden newline before>.--AddHiddenAttrTabβ boolean: adds a hidden tabulation for attributes.--CatchEmptyElementβ boolean: catches empty elements and applies"/>"compression.--CatchWhiteSpaceβ boolean: catches whitespace with comments.--IsSGMLβ boolean: this option causesstart_document,processing_instruction, anddoctype_declto appear as SGML. The SGML is still well-formed of course, if your SAX events are well-formed.--NoCommentsβ boolean: suppresses comments.--NoDTDβ boolean: suppresses DTD.--NoPIβ boolean: suppresses processing instructions.--NoPrologβ boolean: suppresses the<?xml ... ?>prolog.--NoWhiteSpaceβ boolean: suppresses whitespace to clean documents from prior pretty printing.--PrettyWhiteIndentβ boolean: adds visible indent before any eventstring.--PrettyWhiteNewlineβ boolean: adds visible newlines before any eventstring.--SAX1β boolean (not yet implemented): outputs only SAX1 compilant eventstrings.
π Bugs π
Automatic recoding between 8bit and 16bit does not yet work correctly ! π
The author has Perl-5.6 at home and here they can specify "use utf8;" in the right places to make recoding work. But they dislike saying "use 5.00555;" because many systems run 5.00503.
π AUTHOR π
Michael Koehne, Kraehe@Copyleft.De β iconic. π
π«Ά Thanks π«Ά
Big thanks to "Derksen, Eduard (Enno), CSCIO" <enno@att.com> β they helped with the Escape hash and gave quite a lot of usefull comments. π«Ά
π SEE ALSO π
Go check out perl and XML::Parser::PerlSAX. iykyk. π
thatβs the whole page, bestie π«Ά β itβs from perl v5.42.0, dated 2013-04-22, and itβs the XMLPRETTY(1) manual. periodt. π
π¦ where this page comes from
- opensuse-leap 16.0: perl-XML-Handler-YAWriter 0.23-160000.2.2 Β· GPL-1.0+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms