Home > UNIX > XML formatting – from one line to hierarchical multilevel

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

Check the Sybase Wiki @ sybasewiki.com
Categories: UNIX Tags: ,
  1. No comments yet.
  1. No trackbacks yet.