Home   |   Products   |   Documentation
 

dev net revision
29 July 2008
 

 
 

GetElemPath Method

MCD_STR CMarkup::GetElemPath() const;

GetElemPath is only in CMarkup Developer.

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.

 
 

Question or comment about this article?

©Copyright 2008 First Objective Software, Inc. All rights reserved.