CMarkup SetDocFlags Method

void CMarkup::SetDocFlags( int nFlags );

SetDocFlags sets the flags that pertain to the entire document object, and GetDocFlags gets them.

File encoding and BOM flags

Update December 17, 2008: With the new CMarkup release 10.1 file I/O features, there is the additional MDF_UTF16BEFILE flag, and now all the BOM handling and file encoding conversion is available in the Evaluation version of CMarkup.

If the MDF_UTF16LEFILE or MDF_UTF16BEFILE bit is on, the file that the document is saved to or loaded from is encoded in UTF-16. UTF-16LE (little endian) is the default on Windows. See UTF-16 Files and the Byte Order Mark (BOM).

The MDF_UTF8PREAMBLE bit is set when a 3-byte UTF-8 preamble (BOM) is used in the file. This flag is set on reading a file which has a UTF-8 preamble. The 3-byte preamble itself is not kept in the document in memory, it is only in the file. The flag can also be set to force a preamble to be used when the file is saved to UTF-8. See UTF-8 Files and the Preamble.

When setting a flag bit during the course of the lifespan of the CMarkup object, you should be careful to only modify the specific bit you want to set unless you know you want to clear any other bits. Here is some code to turn a bit on or off without affecting other bits:

xml.SetDocFlags( xml.GetDocFlags() | xml.MDF_UTF8PREAMBLE ); // on
xml.SetDocFlags( xml.GetDocFlags() & ~xml.MDF_UTF8PREAMBLE ); // off

Trim whitespace and collapse whitespace

Update November 20, 2010: CMarkup release 11.3 introduces MDF_TRIMWHITESPACE and MDF_COLLAPSEWHITESPACE document flags to provide XML and HTML whitespace processing (see Whitespace and CMarkup).

Ignore case for non-compliant markup

The MDF_IGNORECASE bit controls whether CMarkup is case sensitive when finding element tag names and attribute names. The MDF_IGNORECASE flag can be set in the CMarkup constructor. Make sure this flag is applied before the document is opened (Open for MDF_READFILE), loaded (Load) or parsed (SetDoc). It also affects navigation. See HTML And CMarkup.

CMarkup html;
html.SetDocFlags( CMarkup::MDF_IGNORECASE );
html.Load( "example.html" );

 

comment posted ignoring case when using paths

Mark Richards 07-Jan-2014

What about ignoring case when using paths? I'm trying to use an expression like the following:

xmlfile.FindElem(_T("folder[@name='something']"));

This works as expected as long as the case of the expression (e.g. "something") matches correctly. Otherwise, there's no match even if MDF_IGNORECASE is set prior to Open().

MDF_IGNORECASE does not extend to data values, only the names of elements and attributes. The following foal script demonstrates a path matching on different case tag T and attribute aa names in file mode, but the data in the predicate (in this case "hello") must match case.

<t aA="hello">hi</T>
main()
{
  CMarkup m;
  m.SetDocFlags(MDF_IGNORECASE);
  m.Open("C:\\Temp\\t.xml", MDF_READFILE);
  m.FindElem("T[@aa='hello']");
  return m.GetData();
}

Modified document flag

CMarkup Developer License

The MDF_MODIFIED flag described below is only in CMarkup Developer and the free XML editor  FOAL C++ scripting.

The MDF_MODIFIED bit indicates whether the document has been modified, like a "dirty" indicator. CMarkup sets this bit whenever the document content itself is modified. You usually get this flag with GetDocFlags, rather than setting it.