CMarkup GetElemPath Method

MCD_STR CMarkup::GetElemPath() const;

CMarkup Developer License

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

The GetElemPath method returns the absolute path of the main position element. See Paths In CMarkup.

In the following example XML document there are six elements:

<config>
  <diagnostics d="3">
    <file>C:\temp\a.txt</file>
  </diagnostics>
  <diagnostics d="7">
    <file>D:\temp\a.txt</file>
    <proxy usedefault="true"/>
  </diagnostics>
</config>

This code prints the paths for those six elements.

xml.ResetPos();
while ( xml.FindElem("//*") )
  printf( xml.GetElemPath() );

Every path is unique and provides a way of returning to the element (with the FindElem method) after navigating away from it.

/config
/config/diagnostics
/config/diagnostics/file
/config/diagnostics[2]
/config/diagnostics[2]/file
/config/diagnostics[2]/proxy

However, if the first diagnostics element were removed, the second one would have the path originally associated with the first one. In other words, the path of an element can change when the document changes.

See also GetChildElemPath and GetParentElemPath.