[xml] xmlSaveFormatFileTo



Hello,

These patches add the following function:

int xmlSaveFormatFileTo (xmlOutputBuffer *buf, xmlDocPtr cur, const char
*encoding, int format); 

It's essentially a cross between xmlSaveFormatFile() and
xmlSaveFileTo().  Others may find it useful.  The patches should be
applied to the CVS version.

Cheers,

-Joe M.
-- 
|   Joe McAlerney     joey silicondefense com   |
| Silicon Defense - Technical Support for Snort |
|       http://www.silicondefense.com/          |
+--                                           --+
--- ./XML/tree.c        Fri Apr 27 00:31:13 2001
+++ ./XML.new/tree.c    Fri Apr 27 14:27:24 2001
@@ -6130,6 +6130,27 @@
 }
 
 /**
+ * xmlSaveFormatFileTo:
+ * @buf:  an output I/O buffer
+ * @cur:  the document
+ * @encoding:  the encoding if any assuming the i/O layer handles the trancoding
+ * @format: should formatting spaces been added
+ *
+ * Dump an XML document to an I/O buffer.
+ *
+ * returns: the number of byte written or -1 in case of failure.
+ */
+int
+xmlSaveFormatFileTo(xmlOutputBuffer *buf, xmlDocPtr cur, const char *encoding, int format) {
+  int ret;
+
+  if (buf == NULL) return(0);
+  xmlDocContentDumpOutput(buf, cur, encoding, format);
+  ret = xmlOutputBufferClose(buf);
+  return(ret);
+}
+
+/**
  * xmlSaveFileEnc:
  * @filename:  the filename (or URL)
  * @cur:  the document
--- ./XML/include/libxml/tree.h Fri Apr 27 00:31:13 2001
+++ ./XML.new/include/libxml/tree.h     Fri Apr 27 14:25:33 2001
@@ -689,11 +689,15 @@
                                         int level,
                                         int format);
 
-/* This one is exported from xmlIO.h
+/* These are exported from xmlIO.h
  
 int            xmlSaveFileTo           (xmlOutputBuffer *buf,
                                         xmlDocPtr cur,
                                         const char *encoding);
+int             xmlSaveFormatFileTo     (xmlOutputBuffer *buf,
+                                         xmlDocPtr cur,
+                                         const char *encoding,
+                                         int format);
  */                                     
 
 int            xmlSaveFileEnc          (const char *filename,
--- ./XML/include/libxml/xmlIO.h        Sun Mar 25 00:31:13 2001
+++ ./XML.new/include/libxml/xmlIO.h    Fri Apr 27 14:24:33 2001
@@ -162,6 +162,10 @@
 int            xmlSaveFileTo           (xmlOutputBuffer *buf,
                                         xmlDocPtr cur,
                                         const char *encoding);
+int             xmlSaveFormatFileTo     (xmlOutputBuffer *buf,
+                                        xmlDocPtr cur,
+                                        const char *encoding,
+                                        int format);
 void           xmlNodeDumpOutput       (xmlOutputBufferPtr buf,
                                         xmlDocPtr doc,
                                         xmlNodePtr cur,


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