I have an XML file whose format is quite compressed and all tags are stick together like
<PersonalData><IndividualDetails><Title>Mr</Title><Gender>Male</Gender><FirstName>Hae</FirstName><Surname>JONES</Surname><Occupation>Banker</Occupation><DateofBirth>4/6/76</DateofBirth><LastKnownAddress></LastKnownAddress><LastKnownPostCode>00145</LastKnownPostCode><OtherNames></OtherNames></IndividualDetails><OccupationDetails><Company>SD Bank</Company><CompanyAddress>Sunset Boulevard NY</CompanyAddress><ContactNo>335698457</ContactNo></OccupationDetails></PersonalData>
Is there any command in shell that can properly format the tags. If not indentation only adding the tags to their own lines can also solve my problem.
xmllint --format <your-xml-file>
example
$ cat test.xml
<a><b>c</b></a>
$ xmllint --format test.xml
<a>
<b>c</b>
</a>
$ xmllint --format test.xml > test.formatted.xml
$ cat test.formatted.xml
<a>
<b>c</b>
</a>
$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With