Re: [xml] Pretty print in libxml2



Did you set the indentation settings in the writer?

Best regards: Zoltán Ördögh


On Tue, Apr 23, 2013 at 12:56 PM, <shtil comcast net> wrote:
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>



_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
https://mail.gnome.org/mailman/listinfo/xml




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