我有一个
XML文件,其格式是相当压缩的,所有标签都粘在一起
<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>
xmllint --format <your-xml-file>
例
$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> $