CMarkup ResetChildPos Method

void CMarkup::ResetChildPos()

The ResetChildPos method clears the current child position only, without affecting the main position. This is used to restart a loop through child elements while holding the same main position within the document. It also allows you to add an element as the first child of the main position element when you call InsertChildElem(), or restart a search through child elements.

In this sample document, the ROOT element has three child elements X, Y and Z.

<ROOT>
  <X/>
  <Y/>
  <Z/>
</ROOT>

This code demonstrates that if Z is your current child position you must use ResetChildPos so that FindChildElem can locate the X element.

xml.ResetPos();
xml.FindChildElem( "Z" ); // child is Z
xml.FindChildElem( "X" ); // fails, child is still Z
xml.ResetChildPos();
xml.FindChildElem( "X" ); // child is X

To clear the main position or the entire current position see ResetMainPos and ResetPos.

See Also:

Navigating and Getting Information From a Document
Navigating Levels in CMarkup