LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

xml-format

Pretty-print XML documents

TLDR

Format an XML file with default indentation
$ xml format [input.xml]
copy
Format with a specific number of spaces for indentation
$ xml format --indent-spaces [4] [input.xml]
copy
Format with tab indentation
$ xml format --indent-tab [input.xml]
copy
Format and omit the XML declaration
$ xml format --omit-decl [input.xml]
copy
Recover and format a malformed XML file
$ xml format --recover [input.xml]
copy
Format to output file
$ xml format [input.xml] > [output.xml]
copy

SYNOPSIS

xml format [options] [file]

DESCRIPTION

xml format (also invoked as xml fo) pretty-prints XML documents. Part of the xmlstarlet toolkit. Reformats XML with proper indentation and line breaks for readability. Can also recover malformed XML and convert between encodings.

PARAMETERS

-n, --noindent

Remove indentation from output.
-t, --indent-tab
Indent with tabs.
-s n, --indent-spaces n
Indent with n spaces.
-o, --omit-decl
Omit XML declaration.
-D, --dropdtd
Remove DTD declarations.
-R, --recover
Try to recover malformed XML.
-C, --nocdata
Convert CDATA sections to text nodes.
-N, --nsclean
Remove redundant namespace declarations.
-e encoding, --encode encoding
Output in specified encoding (e.g., utf-8).
-H, --html
Treat input as HTML.

SEE ALSO

Copied to clipboard
Kai