bool CMarkup::AddSubDoc( MCD_CSTR szSubDoc );

The AddSubDoc method is called to add a markup string subdocument after the main position element. If there is no main position, the subdocument is added after the last element under the current parent position. After the subdocument is successfully added, the main position points to the containing element of the new subdocument.

The method returns true if the subdocument is well-formed and added successfully and the main position points to it.

See Subdocuments and Fragments of XML Documents.

CMarkup xml;
xml.AddElem( "DOC" );
xml.IntoElem();
xml.AddSubDoc( "<SUB>Hello World</SUB>\r\n" );
<DOC>
<SUB>Hello World</SUB>
</DOC>

File write mode

Update June 7, 2009: In Release 11.1 AddSubDoc can add subdocuments to files opened with Open in file write mode.

If the subdocument consists of one element without child elements, then the element is kept as the current position and you can still modify attributes. However, if in file write mode the added subdocument has child elements then the current position goes to right after the subdocument.