CMarkup Save Method

bool CMarkup::Save( MCD_CSTR szFileName );

Call Save to write the document to file. For example:

CMarkup xml( "<msg>Hello World</msg>\r\n" );
xml.Save( "C:\\Temp\\hello.xml" );

It will overwrite the file if it exists and create it if it does not. It returns true if the file was successfully written. As explained for the Load and SetDoc methods, the document is written as it exists in the CMarkup object even if it was loaded from a string or file that was not well-formed XML.

If Save returns false, a problem occured writing the file.

After calling Save you can retrieve the result markup string with GetResult to learn the size of the document written, details of a conversion that occurred, or the file error if there was an I/O problem. GetError provides an English version of GetResult.

The Save method calls the WriteTextFile function with the document's flags. So, before calling Save you can set the appropriate flag to cause it to write a UTF-16 file or a UTF-8 BOM (see SetDocFlags).

Update December 17, 2008: With CMarkup release 10.1, the Save and Load methods, and the underlying WriteTextFile and ReadTextFile functions have greatly expanded character conversion capabilities. Save will now encode the file in the ANSI or double-byte encoding specified in the XML declaration or HTML Content-Type meta tag (see GetDeclaredEncoding).