[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [xml] xmlSaveFormatFile not always formatting
- From: Daniel Veillard <veillard redhat com>
- To: Connor Behan <connor behan gmail com>
- Cc: xml gnome org
- Subject: Re: [xml] xmlSaveFormatFile not always formatting
- Date: Wed, 24 Jun 2009 10:55:00 +0200
On Sat, Jun 13, 2009 at 07:47:30PM -0400, Connor Behan wrote:
> My favourite way to format xml is to have indentations and newlines so I
> though xmlSaveFormatFile would be the best function for me to use. It
> outputs xml this way when the xml node it's saving is a newly created
> one with xmlNewDoc... however if I open an existing xml file with
> xmlParseFile and add anything to that node, calling xmlSaveFormat file
> will add the new stuff all on one line.
If libxml2 detects that there is already some text nodes as children of
a node it will disable automatic indenting for the whole subtree.
Formating is an ad-hoc heuristic, the only way to be 100% sure that
the indenting is correct and non-destructive is to add the indentation
(i.e. the extra text nodes) at the application level. libxml2 should not
guess and will default to the safe side.
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel veillard com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]