CMarkup IntoElem Method

bool CMarkup::IntoElem();

IntoElem makes the main position element the parent element. If there is no main position it returns false and does not affect the current position at all.

Here is an example document with 3 levels, a config element which contains a diagnostics element which contains a file element:

<config>
  <diagnostics d="3">
    <file>C:\temp\a.txt</file>
  </diagnostics>
</config>

Here is the simplest way to navigate to the file element:

xml.ResetPos();
xml.FindElem(); // config
xml.IntoElem();
xml.FindElem(); // diagnostics
xml.IntoElem();
xml.FindElem(); // file

There are other ways of getting there such as:

xml.ResetPos();
xml.FindChildElem();
xml.IntoElem(); // diagnostics
xml.FindChildElem( "file" );
xml.IntoElem(); // file

See Navigating Levels in CMarkup.

OutOfElem is the corresponding method for returning back towards the root of the document. Often when you are looping through a document, processing elements, you make sure your IntoElem calls correspond to your OutOfElem calls. For example:

xml.ResetPos();
xml.FindElem();
xml.IntoElem();
while ( xml.FindElem("diagnostics") )
{
  xml.IntoElem();
  while ( xml.FindElem("file") )
    DoSomethingWithFile(xml);
  xml.OutOfElem();
}
xml.OutOfElem();