Re: [xml] Using xmlNewTextWriterTree with indentation



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:eric 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-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

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



-- 
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             (our work)
http://www.vicsmba.com/ourpics/index.html     (fun pictures)


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