- tree.[ch]: added xmlSaveFormatFile interface for saving
and indenting a file.
Daniel
diff --git a/ChangeLog b/ChangeLog
index 6558df0..6b65fc5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Apr 26 20:53:48 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+ * tree.[ch]: added xmlSaveFormatFile interface for saving
+ and indenting a file.
+
Thu Apr 26 16:35:53 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* xpath.c: fixed bug #53689 related to processing-instruction()
diff --git a/include/libxml/tree.h b/include/libxml/tree.h
index be03864..fea27aa 100644
--- a/include/libxml/tree.h
+++ b/include/libxml/tree.h
@@ -680,6 +680,9 @@
xmlNodePtr cur);
int xmlSaveFile (const char *filename,
xmlDocPtr cur);
+int xmlSaveFormatFile (const char *filename,
+ xmlDocPtr cur,
+ int format);
void xmlNodeDump (xmlBufferPtr buf,
xmlDocPtr doc,
xmlNodePtr cur,
diff --git a/tree.c b/tree.c
index 84532a1..965aecd 100644
--- a/tree.c
+++ b/tree.c
@@ -6175,17 +6175,19 @@
}
/**
- * xmlSaveFile:
+ * xmlSaveFormatFile:
* @filename: the filename (or URL)
* @cur: the document
+ * @format: should formatting spaces been added
*
* Dump an XML document to a file. Will use compression if
* compiled in and enabled. If @filename is "-" the stdout file is
- * used.
+ * used. If format is set then the document will be indented on output.
+ *
* returns: the number of byte written or -1 in case of failure.
*/
int
-xmlSaveFile(const char *filename, xmlDocPtr cur) {
+xmlSaveFormatFile(const char *filename, xmlDocPtr cur, int format) {
xmlOutputBufferPtr buf;
const char *encoding;
xmlCharEncodingHandlerPtr handler = NULL;
@@ -6223,9 +6225,24 @@
buf = xmlOutputBufferCreateFilename(filename, handler, cur->compression);
if (buf == NULL) return(-1);
- xmlDocContentDumpOutput(buf, cur, NULL, 0);
+ xmlDocContentDumpOutput(buf, cur, NULL, format);
ret = xmlOutputBufferClose(buf);
return(ret);
}
+/**
+ * xmlSaveFile:
+ * @filename: the filename (or URL)
+ * @cur: the document
+ *
+ * Dump an XML document to a file. Will use compression if
+ * compiled in and enabled. If @filename is "-" the stdout file is
+ * used.
+ * returns: the number of byte written or -1 in case of failure.
+ */
+int
+xmlSaveFile(const char *filename, xmlDocPtr cur) {
+ return(xmlSaveFormatFile(filename, cur, 0));
+}
+
diff --git a/tree.h b/tree.h
index be03864..fea27aa 100644
--- a/tree.h
+++ b/tree.h
@@ -680,6 +680,9 @@
xmlNodePtr cur);
int xmlSaveFile (const char *filename,
xmlDocPtr cur);
+int xmlSaveFormatFile (const char *filename,
+ xmlDocPtr cur,
+ int format);
void xmlNodeDump (xmlBufferPtr buf,
xmlDocPtr doc,
xmlNodePtr cur,