CMarkup Open Method

bool CMarkup::Open( MCD_CSTR szFileName, int nDocFlags, MCD_STR* pstrEncoding=NULL );

CMarkup Developer License

Open is only in CMarkup Developer and the free XML editor  FOAL C++ scripting.

Call Open to open the file for read or write mode with one of the following flags:

MDF_READFILEfile read modeC++ XML reader
MDF_WRITEFILE, MDF_APPENDFILEfile write modeC++ XML writer

For example:

CMarkup xml;
bool bSuccess = xml.Open( "C:\\Temp\\largexmlfile.xml", CMarkup::MDF_READFILE );

If Open is called when the object has been populated in regular mode, the in-memory document is discarded. CMarkup's m_strDoc string member is used as an in-memory partial document buffer in both file modes like a window into a portion of the document while reading or writing.

Open returns true if the file is successfully opened according to the value of nDocFlags. If Open returns false, the error string can be retrieved with GetError.

After Open, and until Close, the methods you can use are restricted based on the file mode. The allowed mehods are documented in the reader and writer reference.

When opening a file in write mode you can combine (logical OR) the encoding/BOM bit flags into the nDocFlags argument, or set them with the SetDocFlags method beforehand.

MDF_UTF16LEFILEUTF-16LE encoding (BOM is always included)
MDF_UTF16BEFILEUTF-16BE encoding (BOM is always included)
MDF_UTF8PREAMBLEuse UTF-8 preamble (also called BOM)

In file read mode, you can determine whether the file was UTF-16 or had a UTF-8 preamble by calling the GetDocFlags method after Open.

The pstrEncoding argument can be specified for either mode. For write mode you can specify the ANSI or double-byte encoding to be used. For read mode it will return the ANSI or double-byte encoding name that was determined.

The MDF_APPENDFILE functionality is limited to documents without a root element. It does not parse the file so it does not know the context to which it is appending markup data.