CMarkup GetDoc Method

const MCD_STR& CMarkup::GetDoc() const;

The GetDoc method can be used at any time to get the full text of the CMarkup object XML document. For example:

CMarkup xml;
xml.AddElem( "msg", "Hello World" );
str sXML = xml.GetDoc();
<msg>Hello World</msg>

The document and current position are not affected by this call. It is generally used after creating or modifying the document when it is time to transport or save the document. As explained for the Load and SetDoc methods, the document is retrieved as it exists in the CMarkup object even if it was set from a string or file that was not well-formed XML.

Update March 24, 2009: GetDoc can be used with CMarkup release 11.0 developer version file read mode (see C++ XML reader) and file write mode (see C++ XML writer), but only to get the current partial document markup string which in read mode is the most recently retrieved from the file, and in write mode is the text not yet written to the file stream.

See also ReadTextFile.

 

comment posted ls_what is empty

Vaclav 08-Jun-2007

That code produces the following document, and the current position ends on the hihihi element, and hihihi is an empty element, so GetData should return an empty string.

<blabla>
<hihihi/>
</blabla>

If you want hihihi to be an element, and you want the hihihi subdocument see GetSubDoc, or the XML content of blabla then see GetElemContent.

If you want hihihi to be the data of the blabla element:

<blabla>hihihi</blabla>

Here are three different ways of creating this document:

l_markup.AddElem( "blabla" );
l_markup.SetData( "hihihi" );
l_markup.AddElem( "blabla", "hihihi" );
l_markup.AddElem( "blabla" );
l_markup.IntoElem();
l_markup.AddNode( CMarkup::MNT_TEXT, "hihihi" );
l_markup.OutOfElem()

Then GetData will return "hihihi".