Here is synopsis for 'xml fo' command:
XMLStarlet Toolkit: Format XML document Usage: xml fo [<options>] <xml-file> where <options> are -n or --noindent - do not indent -t or --indent-tab - indent output with tabulation -s or --indent-spaces <num> - indent output with <num> spaces -o or --omit-decl - omit xml declaration <?xml version="1.0"?> -R or --recover - try to recover what is parsable -D or --dropdtd - remove the DOCTYPE of the input docs -C or --nocdata - replace cdata section with text nodes -N or --nsclean - remove redundant namespace declarations -e or --encode <encoding> - output in the given encoding (utf-8, unicode...) -H or --html - input is HTML -h or --help - print help XMLStarlet is a command line toolkit to query/edit/check/transform XML documents (for more information see http://xmlstar.sourceforge.net/)
EXAMPLE
# Format XML document disabling indent cat xml/tab-obj.xml | xml fo --noindent
Output:
<xml> <table> <rec id="1"> <numField>123</numField> <stringField>String Value</stringField> <object name="Obj1"> <property name="size">10</property> <property name="type">Data</property> </object> </rec> <rec id="2"> <numField>346</numField> <stringField>Text Value</stringField> </rec> <rec id="3"> <numField>-23</numField> <stringField>stringValue</stringField> </rec> </table> </xml>
EXAMPLE
# Recover malformed XML document xml fo -R xml/malformed.xml 2>/dev/null
Input:
<test_output> <test_name>foo</testname> <subtest>...</subtest> </test_output>
Output:
<test_output> <test_name>foo</test_name> <subtest>...</subtest> </test_output>