[xml] Pretty print in libxml2



Hi,

I wonder if there is a way to pretty print xml.
Referring to the examples for xmlWriter I want 

<?xml version="1.0" encoding="ISO-8859-1"?>
<EXAMPLE><!--This is a comment with special chars: <äöü>--><ORDER version="1.0" xml:lang="de"><!--This is another comment with special chars: <äöü>--><HEADER><X_ORDER_ID>0000053535</X_ORDER_ID><CUSTOMER_ID>1010</CUSTOMER_ID><NAME_1>Müller</NAME_1><NAME_2>Jörg</NAME_2></HEADER><ENTRIES><ENTRY><ARTICLE>&lt;Test&gt;</ARTICLE><ENTRY_NO>10</ENTRY_NO></ENTRY><ENTRY><ARTICLE>&lt;Test 2&gt;</ARTICLE><ENTRY_NO>20</ENTRY_NO></ENTRY></ENTRIES><FOOTER><TEXT>This is a text.</TEXT></FOOTER></ORDER></EXAMPLE>

to look like:

<?xml version="1.0" encoding="ISO-8859-1"?>
<EXAMPLE>
  <!--This is a comment with special chars: <äöü>-->
  <ORDER version="1.0" xml:lang="de">
    <!--This is another comment with special chars: <äöü>-->
    <HEADER>
      <X_ORDER_ID>0000053535</X_ORDER_ID>
      <CUSTOMER_ID>1010</CUSTOMER_ID>
      <NAME_1>Müller</NAME_1>
      <NAME_2>Jörg</NAME_2>
    </HEADER>
    <ENTRIES>
      <ENTRY>
        <ARTICLE>&lt;Test&gt;</ARTICLE>
        <ENTRY_NO>10</ENTRY_NO>
      </ENTRY>
      <ENTRY>
        <ARTICLE>&lt;Test 2&gt;</ARTICLE>
        <ENTRY_NO>20</ENTRY_NO>
      </ENTRY>
    </ENTRIES>
    <FOOTER>
      <TEXT>This is a text.</TEXT>
    </FOOTER>
</ORDER>
</EXAMPLE>




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]