XML formatting – from one line to hierarchical multilevel
Problem: How to convert a xml file which is having data in a single time to multiline multilevel hierarchial format as below…
source_xml.xml:
———-
<header><sequence_no>12345</sequence_no><Sender_id>2341</sender_id><receipient_id><ref_no>5678</ref_no></receipient_id></header>
destination_xml.xml:
—————
<header>
<sequence_no>12345</sequence_no>
<Sender_id>2341</sender_id>
<receipient_id>
<ref_no>5678</ref_no>
</receipient_id>
</header>
Solution: Use command line tool xmllint
usage:
——
xmllint -htmlout -format source_xml.xml > destination_xml.xml