CMarkup FindGetData Method
MCD_STR CMarkup::FindGetData( MCD_CSTR szName );
|
|
The FindGetData method combines the FindElem method with the GetData method. It finds the element, sets that element as the main position element, and returns its string data value. If the element is not found or is empty, it returns an empty string. If the element is found, it is set as the current main position whether or not it is an empty element. If this main position element contains child elements, the return value is an empty string (as in GetData).
Together with the FindSetData method, this is ideal for keeping configuration and messaging structures in XML documents. See Dynamic Structure Documents.
See the FindElem method for details on using the szName argument. FindGetData is a powerful way to determine a data value from a document with a single method. It only takes one call to retrieve any of the configuration information from the following document:
<Configuration>
<Dir>C:\Temp</Dir>
<ShowUser>1</ShowUser>
<Default>67</Default>
<WindowPos>
<Left>100</Left>
<Top>50</Top>
<Right>400</Right>
<Bottom>350</Bottom>
</WindowPos>
</Configuration>
str sVal = FindGetData("/Configuration/Dir"); // C:\Temp
sVal = FindGetData("/*/WindowPos/Right"); // 400

