MCD_STR CMarkup::FindGetData( MCD_CSTR szName );

CMarkup Developer License

FindGetData is only in CMarkup Developer and the free XML editor  FOAL C++ scripting.

The FindGetData method combines the FindElem method with the GetData method and adds the option of getting an attribute value. It finds the element, sets that element as the main position element, and returns its string data value or the specified attribute value. If the element is not found, it returns an empty string. If the element is found, it is set as the current main position. If the element data value is requested and the element is empty or it contains child elements, the return value is an empty string (as in GetData).

Update June 7, 2009: In release 11.1 FindGetData can get an attribute value.

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:

  <Dir nickname="temp">C:\Temp</Dir>
FindGetData("/Configuration/Dir"); // C:\Temp
FindGetData("/Configuration/Dir/@nickname"); // temp
FindGetData("/*/WindowPos/Right"); // 400

Update March 24, 2009: FindGetData can be used with CMarkup release 11.0 developer version file read mode (see C++ XML reader). Unlike in regular mode, if an element is not found in file read mode then the current position will be at the end tag of the parent element or at the end of the document if the starting position was not within a parent element. In paths, child predicates are not supported.