bool CMarkup::InsertNode( int nNodeType, MCD_CSTR szText );

The InsertNode method is called to add a node before the main position. If there is no main position, the node is added as the first node under the current parent position element. After a node is successfully inserted, the main position points to the new node.

The following example shows how to insert an XML version (XML Declaration) at the beginning of an existing document with a root element. If the document is non-empty it is necessary to use InsertNode instead of AddNode). And if there is no current main position, it is guaranteed to be at the beginning of the document even if there is a DTD.

xml.InsertNode( MNT_PROCESSING_INSTRUCTION, "xml" );
xml.SetAttrib( "version", "1.0" );
<?xml version="1.0"?>

See the Node Methods in CMarkup.