XML格式化缩进标签匹配 – Linux

我有一个 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>

shell中是否有任何可以正确格式化标签的命令.如果不缩进,只需将标签添加到自己的行也可以解决我的问题.

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>
$

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念