Quite right. After more research, I found that the correct API for my purposes 
is

xmlDocSaveFormatFileEnc()

so that encoding of the generated file will be handled properly.
MV

From: Eric S. Eberhard [mailto:e...@vicsmba.com]
Sent: March 22, 2017 15:05
To: Vuille, Martin (Martin)
Cc: xml@gnome.org
Subject: Re: [xml] Using xmlNewTextWriterTree with indentation

That is funny.  We often get XML in with no CR or LF or EOF which when they are 
large are not really possible to read.  We have a tiny program that simply 
loads the doc and re-writes it with:

xmlDocFormatDump()

We then get something we can read!  What a deal.  So it is good not only for 
your stuff, but debugging what comes in.

E


On 3/22/2017 5:55 AM, Vuille, Martin (Martin) wrote:
Never mind, fixed my own problem.

I was using xmlTextWriterSetIndent() to enable identing
and xmlSaveFileEnc() to write the doc to a file.

Switching to xmlDocFormatDump() for writing gives me
the result I need.

MV

From: xml [mailto:xml-boun...@gnome.org] On Behalf Of Vuille, Martin (Martin)
Sent: March 21, 2017 16:30
To: xml@gnome.org<mailto:xml@gnome.org>
Subject: [xml] Using xmlNewTextWriterTree with indentation

I am trying to use xmlNewTextWriterTree to add some elements
to a doc tree. I would like the new elements to be indented according
to their depth in the tree. But it seems the indentation level is starting
from 0.

Is there a different way for me to go about this?

I have:

<A>
  <B>
  </B>
</A>

I am using xmlNewTextWriterTree with the 'node' argument pointing
to the 'B' element.

I would like to end up with something like this:

<A>
  <B>
    <C>
      <D>
      </D>
    </C>
  </B>
<A>

But instead I get:

<A>
  <B><C>
  <D>
  </D>
<C></B>
</A>

Any pointers appreciated.
MV





_______________________________________________

xml mailing list, project page  
http://xmlsoft.org/<https://urldefense.proofpoint.com/v2/url?u=http-3A__xmlsoft.org_&d=DwMCAw&c=BFpWQw8bsuKpl1SgiZH64Q&r=SbT_XjBLTrjzWy1iRhblzG3bKRhcodBp7tD_mnp1dpg&m=cHIz7wEl5GEXo_PbmTlLIepOKfHoIIxquAvOgekJ05o&s=RPylWQ0el8Gi9hRPFNcx7at3EvZ4Xq-lqXw-FxW2LPw&e=>

xml@gnome.org<mailto:xml@gnome.org>

https://mail.gnome.org/mailman/listinfo/xml<https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.gnome.org_mailman_listinfo_xml&d=DwMCAw&c=BFpWQw8bsuKpl1SgiZH64Q&r=SbT_XjBLTrjzWy1iRhblzG3bKRhcodBp7tD_mnp1dpg&m=cHIz7wEl5GEXo_PbmTlLIepOKfHoIIxquAvOgekJ05o&s=vx3SVeA7tbKumw2Izj6hIOqwLBeTsWz2RblINwrpDCk&e=>





--

Eric S. Eberhard

VICS

2933 W Middle Verde Road

Camp Verde, AZ  86322



928-567-3727  work                      928-301-7537  cell



http://www.vicsmba.com/index.html<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.vicsmba.com_index.html&d=DwMCAw&c=BFpWQw8bsuKpl1SgiZH64Q&r=SbT_XjBLTrjzWy1iRhblzG3bKRhcodBp7tD_mnp1dpg&m=cHIz7wEl5GEXo_PbmTlLIepOKfHoIIxquAvOgekJ05o&s=l3ql58Ahfwycrgcj_40qkJ04Sz2lVwmAtGd0VrHGPkM&e=>
             (our work)

http://www.vicsmba.com/ourpics/index.html<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.vicsmba.com_ourpics_index.html&d=DwMCAw&c=BFpWQw8bsuKpl1SgiZH64Q&r=SbT_XjBLTrjzWy1iRhblzG3bKRhcodBp7tD_mnp1dpg&m=cHIz7wEl5GEXo_PbmTlLIepOKfHoIIxquAvOgekJ05o&s=HSAO5SO-RVpSjcow2rm5JzCcuMvp-ZdcyxYSD1qG8Lo&e=>
     (fun pictures)
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml

Reply via email to