# ## Module xmlsave from libxml2

API Menu
Main Menu Developer Menu Code Examples API Menu Parser API Tree API Reader API XML Guidelines ChangeLog
API Indexes
Alphabetic Constructors Functions/Types Modules Symbols
Related links
Mail archive XSLT libxslt DOM gdome2 XML-DSig xmlsec FTP Windows binaries Solaris binaries MacOsX binaries Pascal bindings Bug Tracker
API to save document or subtree of document ## Table of Contents
    Structure xmlSaveCtxt
    struct _xmlSaveCtxt
    The content of this structure is not made public by the API.
    Typedef xmlSaveCtxt * xmlSaveCtxtPtr
    int	xmlSaveClose			(xmlSaveCtxtPtr ctxt)
    long	xmlSaveDoc			(xmlSaveCtxtPtr ctxt,
    					 xmlDocPtr doc)
    int	xmlSaveFlush			(xmlSaveCtxtPtr ctxt)
    int	xmlSaveSetAttrEscape		(xmlSaveCtxtPtr ctxt,
    					 xmlCharEncodingOutputFunc escape)
    int	xmlSaveSetEscape		(xmlSaveCtxtPtr ctxt,
    					 xmlCharEncodingOutputFunc escape)
    xmlSaveCtxtPtr	xmlSaveToFd		(int fd,
    					 const char * encoding,
    					 int options)
    xmlSaveCtxtPtr	xmlSaveToFilename	(const char * filename,
    					 const char * encoding,
    					 int options)
    xmlSaveCtxtPtr	xmlSaveToIO		(xmlOutputWriteCallback iowrite,
    					 xmlOutputCloseCallback ioclose,
    					 void * ioctx,
    					 const char * encoding,
    					 int options)
    long	xmlSaveTree			(xmlSaveCtxtPtr ctxt,
    					 xmlNodePtr node)
## Description ### Structure xmlSaveCtxt
    Structure xmlSaveCtxt
    struct _xmlSaveCtxt {
    The content of this structure is not made public by the API.
    }
### Function: xmlSaveClose
    int	xmlSaveClose			(xmlSaveCtxtPtr ctxt)
Close a document saving context, i.e. make sure that all bytes have been output and free the associated data.
`ctxt`: | a document saving context
`Returns`: | the number of byte written or -1 in case of error.
### Function: xmlSaveDoc
    long	xmlSaveDoc			(xmlSaveCtxtPtr ctxt,
    					 xmlDocPtr doc)
Save a full document to a saving context TODO: The function is not fully implemented yet as it does not return the byte count but 0 instead
`ctxt`: | a document saving context
`doc`: | a document
`Returns`: | the number of byte written or -1 in case of error
### Function: xmlSaveFlush
    int	xmlSaveFlush			(xmlSaveCtxtPtr ctxt)
Flush a document saving context, i.e. make sure that all bytes have been output.
`ctxt`: | a document saving context
`Returns`: | the number of byte written or -1 in case of error.
### Function: xmlSaveSetAttrEscape
    int	xmlSaveSetAttrEscape		(xmlSaveCtxtPtr ctxt,
    					 xmlCharEncodingOutputFunc escape)
Set a custom escaping function to be used for text in attribute content
`ctxt`: | a document saving context
`escape`: | the escaping function
`Returns`: | 0 if successful or -1 in case of error.
### Function: xmlSaveSetEscape
    int	xmlSaveSetEscape		(xmlSaveCtxtPtr ctxt,
    					 xmlCharEncodingOutputFunc escape)
Set a custom escaping function to be used for text in element content
`ctxt`: | a document saving context
`escape`: | the escaping function
`Returns`: | 0 if successful or -1 in case of error.
### Function: xmlSaveToFd
    xmlSaveCtxtPtr	xmlSaveToFd		(int fd,
    					 const char * encoding,
    					 int options)
Create a document saving context serializing to a file descriptor with the encoding and the options given.
`fd`: | a file descriptor number
`encoding`: | the encoding name to use or NULL
`options`: | a set of xmlSaveOptions
`Returns`: | a new serialization context or NULL in case of error.
### Function: xmlSaveToFilename
    xmlSaveCtxtPtr	xmlSaveToFilename	(const char * filename,
    					 const char * encoding,
    					 int options)
Create a document saving context serializing to a filename or possibly to an URL (but this is less reliable) with the encoding and the options given.
`filename`: | a file name or an URL
`encoding`: | the encoding name to use or NULL
`options`: | a set of xmlSaveOptions
`Returns`: | a new serialization context or NULL in case of error.
### Function: xmlSaveToIO
    xmlSaveCtxtPtr	xmlSaveToIO		(xmlOutputWriteCallback iowrite,
    					 xmlOutputCloseCallback ioclose,
    					 void * ioctx,
    					 const char * encoding,
    					 int options)
Create a document saving context serializing to a file descriptor with the encoding and the options given
`iowrite`: | an I/O write function
`ioclose`: | an I/O close function
`ioctx`: | an I/O handler
`encoding`: | the encoding name to use or NULL
`options`: | a set of xmlSaveOptions
`Returns`: | a new serialization context or NULL in case of error.
### Function: xmlSaveTree
    long	xmlSaveTree			(xmlSaveCtxtPtr ctxt,
    					 xmlNodePtr node)
Save a subtree starting at the node parameter to a saving context TODO: The function is not fully implemented yet as it does not return the byte count but 0 instead
`ctxt`: | a document saving context
`node`: | a document
`Returns`: | the number of byte written or -1 in case of error
Daniel Veillard