Function SaveFile

Summary

#include <tinyxml2.h>

(1) XMLError SaveFile(const char *filename, bool compact=false)

(2) XMLError SaveFile(FILE *fp, bool compact=false)

Function overload

Synopsis

#include <tinyxml2.h>

XMLError SaveFile(const char *filename, bool compact=false)

Description

Save the XML file to disk. Returns XML_SUCCESS (0) on success, or an errorID.

Mentioned in

Source

Lines 2357-2373 in tinyxml2.cpp. Line 1776 in tinyxml2.h.

XMLError XMLDocument::SaveFile( const char* filename, bool compact )
{
    if ( !filename ) {
        TIXMLASSERT( false );
        SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, 0, "filename=<null>" );
        return _errorID;
    }

    FILE* fp = callfopen( filename, "w" );
    if ( !fp ) {
        SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, 0, "filename=%s", filename );
        return _errorID;
    }
    SaveFile(fp, compact);
    fclose( fp );
    return _errorID;
}

Synopsis

#include <tinyxml2.h>

XMLError SaveFile(FILE *fp, bool compact=false)

Description

Save the XML file to disk. You are responsible for providing and closing the FILE*.

Returns XML_SUCCESS (0) on success, or an errorID.

Mentioned in

Source

Lines 2376-2384 in tinyxml2.cpp. Line 1785 in tinyxml2.h.

XMLError XMLDocument::SaveFile( FILE* fp, bool compact )
{
    // Clear any error from the last save, otherwise it will get reported
    // for *this* call.
    ClearError();
    XMLPrinter stream( fp, compact );
    Print( &stream );
    return _errorID;
}





Add Discussion as Guest

Log in