Re: [xml] Using xmlNewTextWriterTree with indentation



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-bounces gnome org] On Behalf Of Vuille, Martin (Martin)
Sent: March 21, 2017 16:30
To: 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



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