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/ [email protected] | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ _______________________________________________ xml mailing list, project page http://xmlsoft.org/ [email protected] http://mail.gnome.org/mailman/listinfo/xml
