Re: [libxml++] writing formatted (indented) files
- From: Christophe de Vienne <cdevienne alphacent com>
- To: libxmlplusplus-general lists sourceforge net
- Subject: Re: [libxml++] writing formatted (indented) files
- Date: Thu, 8 May 2003 14:13:24 +0200
Le Jeudi 8 Mai 2003 08:20, Murray Cumming Comneon com a écrit :
> > From: Eric Bourque [mailto:ericb computer org]
> > Is there a way to write a formatted file using
> > Document::write_to_file()
> > in libxml++?
>
The function used to write to file is xmlSaveFormatFile or
xmlSaveFormatFileEnc depending on the given encoding parameter.
The 'format' parameter is set to 1.
Reading libxml2 doc for xmlSaveFormatFile:
"Note that format = 1 provide node indenting only if xmlIndentTreeOutput = 1
or xmlKeepBlanksDefault(0) was called"
consider this other extract from the doc :
#define xmlIndentTreeOutput
Global setting, asking the serializer to indent the output tree by default
Enabled by default
So the only thing we need is to call xmlKeepBlanksDefault(0), which is done in
the parse_xx methods.
The consequence is that, theoraticaly, the output will be formatted only if
something has been parsed before (I did not test this behavior).
I think that the most simple thing to do is to call xmlKeepBlanksDefault(0) in
write_to functions.
On the other hand we'll have it called more than necessary. So we could call
it in Document::Init::Init() and remove it everywere else.
If you agree with that I'll commit a patch soon.
Cheers
Christophe
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]