2021-08-16 08:23:55 -04:00
|
|
|
# xml format
|
2021-08-14 18:17:52 -04:00
|
|
|
|
2021-08-15 14:38:24 -04:00
|
|
|
> Format an XML document.
|
2025-05-11 21:14:19 +03:00
|
|
|
> More information: <https://xmlstar.sourceforge.net/doc/UG/xmlstarlet-ug.html#idm47077139569312>.
|
2021-08-14 18:17:52 -04:00
|
|
|
|
2021-08-15 14:38:24 -04:00
|
|
|
- Format an XML document, indenting with tabs:
|
|
|
|
|
2025-05-11 21:14:19 +03:00
|
|
|
`xml {{[fo|format]}} {{[-t|--indent-tab]}} {{path/to/input.xml|URI}} > {{path/to/output.xml}}`
|
2021-08-15 14:38:24 -04:00
|
|
|
|
|
|
|
- Format an HTML document, indenting with 4 spaces:
|
|
|
|
|
2025-05-11 21:14:19 +03:00
|
|
|
`xml {{[fo|format]}} {{[-H|--html]}} {{[-s|--indent-spaces]}} {{4}} {{path/to/input.html|URI}} > {{path/to/output.html}}`
|
2021-08-15 14:38:24 -04:00
|
|
|
|
|
|
|
- Recover parsable parts of a malformed XML document, without indenting:
|
|
|
|
|
2025-05-11 21:14:19 +03:00
|
|
|
`xml {{[fo|format]}} {{[-R|--recover]}} {{[-n|--noindent]}} {{path/to/malformed.xml|URI}} > {{path/to/recovered.xml}}`
|
2021-08-15 14:38:24 -04:00
|
|
|
|
2022-12-04 08:53:34 +01:00
|
|
|
- Format an XML document from `stdin`, removing the `DOCTYPE` declaration:
|
2021-08-15 14:38:24 -04:00
|
|
|
|
2025-05-11 21:14:19 +03:00
|
|
|
`cat {{path\to\input.xml}} | xml {{[fo|format]}} {{[-D|--dropdtd]}} > {{path/to/output.xml}}`
|
2021-08-15 14:38:24 -04:00
|
|
|
|
|
|
|
- Format an XML document, omitting the XML declaration:
|
|
|
|
|
2025-05-11 21:14:19 +03:00
|
|
|
`xml {{[fo|format]}} {{[-o|--omit-decl]}} {{path\to\input.xml|URI}} > {{path/to/output.xml}}`
|
2021-08-15 14:38:24 -04:00
|
|
|
|
2024-01-30 01:55:24 -03:00
|
|
|
- Display help:
|
2021-08-14 18:17:52 -04:00
|
|
|
|
2025-05-11 21:14:19 +03:00
|
|
|
`xml {{[fo|format]}} --help`
|